|
1 |
| -# Flutter Geocoding Plugin |
| 1 | +# Flutter Geocoding Plugin |
2 | 2 |
|
3 | 3 | [](https://pub.dartlang.org/packages/geocoding)
|
4 | 4 | [](https://opensource.org/licenses/MIT)
|
5 | 5 | [](https://github.com/tenhobi/effective_dart)
|
6 |
| -[](https://github.com/Baseflow/flutter-geocoding/actions?query=workflow%3AGeocoding) |
| 6 | +[](https://github.com/Baseflow/flutter-geocoding/actions/workflows/geocoding.yaml) |
7 | 7 | [](https://codecov.io/gh/Baseflow/flutter-geocoding)
|
8 | 8 |
|
9 | 9 | A Flutter Geocoding plugin which provides easy geocoding and reverse-geocoding features.
|
10 | 10 |
|
11 |
| -**Important**: |
| 11 | +**Important**: |
12 | 12 |
|
13 | 13 | 1. This plugin uses the free Geocoding services provided by the iOS and Android platforms. This means that there are restrictions to their use. More information can be found in the [Apple documentation for iOS](https://developer.apple.com/documentation/corelocation/clgeocoder) and the [Google documentation for Android](https://developer.android.com/reference/android/location/Geocoder).
|
14 | 14 | When a `PlatformException(IO_ERROR, ...)` gets thrown, most of the times it means that the rate limit has been reached.
|
15 |
| -2. The availability of the Google Play Services depends on your country. If your country doesn't support a connection with the Google Play Services, you'll need to try a VPN to establish a connection. For more information about how to work with Google Play Services visit the following link: https://developers.google.com/android/guides/overview |
| 15 | +2. The availability of the Google Play Services depends on your country. If your country doesn't support a connection with the Google Play Services, you'll need to try a VPN to establish a connection. For more information about how to work with Google Play Services visit the following link: https://developers.google.com/android/guides/overview |
16 | 16 |
|
17 | 17 | ## Usage
|
18 | 18 |
|
19 | 19 | To use this plugin, please follow the installation guide on the [official geocoding plugin page](https://pub.dev/packages/geocoding/install).
|
20 | 20 |
|
21 |
| -> **NOTE:** This plugin relies on the AndroidX version of the Android Support Libraries. This means you need to make sure your Android project is also upgraded to support AndroidX. Detailed instructions can be found [here](https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility). |
| 21 | +> **NOTE:** This plugin relies on the AndroidX version of the Android Support Libraries. This means you need to make sure your Android project is also upgraded to support AndroidX. Detailed instructions can be found [here](https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility). |
22 | 22 | >
|
23 |
| ->The TL;DR version is: |
| 23 | +> The TL;DR version is: |
24 | 24 | >
|
25 |
| ->1. Add the following to your "gradle.properties" file: |
| 25 | +> 1. Add the following to your "gradle.properties" file: |
26 | 26 | >
|
27 |
| ->``` |
28 |
| ->android.useAndroidX=true |
29 |
| ->android.enableJetifier=true |
30 |
| ->``` |
31 |
| ->2. Make sure you set the `compileSdkVersion` in your "android/app/build.gradle" file to 33: |
| 27 | +> ```properties |
| 28 | +> android.useAndroidX=true |
| 29 | +> android.enableJetifier=true |
| 30 | +> ``` |
32 | 31 | >
|
33 |
| ->``` |
34 |
| ->android { |
35 |
| -> compileSdkVersion 33 |
| 32 | +> 2. Make sure you set the `compileSdkVersion` in your "android/app/build.gradle" file to 33: |
36 | 33 | >
|
37 |
| -> ... |
38 |
| ->} |
39 |
| ->``` |
40 |
| ->3. Make sure you replace all the `android.` dependencies to their AndroidX counterparts (a full list can be found [Android migration guide](https://developer.android.com/jetpack/androidx/migrate)). |
| 34 | +> ```gradle |
| 35 | +> android { |
| 36 | +> compileSdkVersion 33 |
| 37 | +> |
| 38 | +> ... |
| 39 | +> } |
| 40 | +> ``` |
| 41 | +> |
| 42 | +> 3. Make sure you replace all the `android.` dependencies to their AndroidX counterparts (a full list can be found [Android migration guide](https://developer.android.com/jetpack/androidx/migrate)). |
41 | 43 |
|
42 | 44 | ## API
|
43 | 45 |
|
44 | 46 | To translate an address into latitude and longitude coordinates you can use the `placemarkFromAddress` method:
|
45 | 47 |
|
46 |
| -``` dart |
| 48 | +```dart |
47 | 49 | import 'package:geocoding/geocoding.dart';
|
48 | 50 |
|
49 | 51 | List<Location> locations = await locationFromAddress("Gronausestraat 710, Enschede");
|
50 | 52 | ```
|
51 | 53 |
|
52 | 54 | If you want to translate latitude and longitude coordinates into an address you can use the `placemarkFromCoordinates` method:
|
53 | 55 |
|
54 |
| -``` dart |
| 56 | +```dart |
55 | 57 | import 'package:geocoding/geocoding.dart';
|
56 | 58 |
|
57 | 59 | List<Placemark> placemarks = await placemarkFromCoordinates(52.2165157, 6.9437819);
|
58 | 60 | ```
|
59 | 61 |
|
60 |
| -The setLocaleIdentifier with the `localeIdentifier` parameter can be used to enforce the results to be formatted (and translated) according to the specified locale. The `localeIdentifier` should be formatted using the syntax: [languageCode]_[countryCode]. Use the [ISO 639-1 or ISO 639-2](https://www.loc.gov/standards/iso639-2/php/English_list.php) standard for the language code and the 2 letter [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard for the country code. Some examples are: |
| 62 | +The setLocaleIdentifier with the `localeIdentifier` parameter can be used to enforce the results to be formatted (and translated) according to the specified locale. The `localeIdentifier` should be formatted using the syntax: [languageCode]\_[countryCode]. Use the [ISO 639-1 or ISO 639-2](https://www.loc.gov/standards/iso639-2/php/English_list.php) standard for the language code and the 2 letter [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard for the country code. Some examples are: |
61 | 63 |
|
62 |
| -Locale identifier | Description |
63 |
| ------------------ | ----------- |
64 |
| -en | All English speakers (will translate all attributes to English) |
65 |
| -en_US | English speakers in the United States of America |
66 |
| -en_UK | English speakers in the United Kingdom |
67 |
| -nl_NL | Dutch speakers in The Netherlands |
68 |
| -nl_BE | Dutch speakers in Belgium |
| 64 | +| Locale identifier | Description | |
| 65 | +| ----------------- | --------------------------------------------------------------- | |
| 66 | +| en | All English speakers (will translate all attributes to English) | |
| 67 | +| en_US | English speakers in the United States of America | |
| 68 | +| en_UK | English speakers in the United Kingdom | |
| 69 | +| nl_NL | Dutch speakers in The Netherlands | |
| 70 | +| nl_BE | Dutch speakers in Belgium | |
69 | 71 |
|
70 | 72 | ## Issues
|
71 | 73 |
|
|
0 commit comments