@capgo/nativegeocoder 0.1.26 → 0.1.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
11
11
  s.author = package['author']
12
12
  s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
13
  s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
- s.ios.deployment_target = '12.0'
14
+ s.ios.deployment_target = '13.0'
15
15
  s.dependency 'Capacitor'
16
16
  s.swift_version = '5.1'
17
17
  end
@@ -1,27 +1,27 @@
1
1
  ext {
2
- junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.1'
3
- androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.2.0'
4
- androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.2'
5
- androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.3.0'
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.3'
4
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.4.0'
5
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.4.2'
6
6
  }
7
7
 
8
8
  buildscript {
9
9
  repositories {
10
+ mavenCentral()
10
11
  google()
11
- jcenter()
12
12
  }
13
13
  dependencies {
14
- classpath 'com.android.tools.build:gradle:4.2.1'
14
+ classpath 'com.android.tools.build:gradle:7.2.1'
15
15
  }
16
16
  }
17
17
 
18
18
  apply plugin: 'com.android.library'
19
19
 
20
20
  android {
21
- compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 30
21
+ compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
22
22
  defaultConfig {
23
- minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 21
24
- targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 30
23
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
24
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
25
25
  versionCode 1
26
26
  versionName "1.0"
27
27
  testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -6,26 +6,25 @@ import android.location.Geocoder;
6
6
  import android.net.ConnectivityManager;
7
7
  import android.net.NetworkInfo;
8
8
  import android.os.Build;
9
-
10
9
  import com.getcapacitor.JSObject;
11
10
  import com.getcapacitor.PluginCall;
12
-
13
- import org.json.JSONArray;
14
- import org.json.JSONObject;
15
-
16
11
  import java.util.List;
17
12
  import java.util.Locale;
13
+ import org.json.JSONArray;
14
+ import org.json.JSONObject;
18
15
 
19
16
  class NativeGeocoderOptions {
20
- boolean useLocale = true;
21
- String defaultLocale = null;
22
- int maxResults = 1;
17
+
18
+ boolean useLocale = true;
19
+ String defaultLocale = null;
20
+ int maxResults = 1;
23
21
  }
24
22
 
25
23
  public class NativeGeocoder {
26
24
 
27
25
  private Geocoder geocoder;
28
26
  public Context context;
27
+
29
28
  /**
30
29
  * Reverse geocode a given latitude and longitude to find location address
31
30
  * @param latitude double
@@ -33,7 +32,6 @@ public class NativeGeocoder {
33
32
  * @param call PluginCall
34
33
  */
35
34
  public void reverseGeocode(double latitude, double longitude, PluginCall call) {
36
-
37
35
  if (latitude == 0 || longitude == 0) {
38
36
  call.reject("Expected two non-empty double arguments.");
39
37
  return;
@@ -69,7 +67,10 @@ public class NativeGeocoder {
69
67
  placemark.put("subLocality", address.getSubLocality() != null ? address.getSubLocality() : "");
70
68
  placemark.put("thoroughfare", address.getThoroughfare() != null ? address.getThoroughfare() : "");
71
69
  placemark.put("subThoroughfare", address.getSubThoroughfare() != null ? address.getSubThoroughfare() : "");
72
- placemark.put("areasOfInterest", address.getFeatureName() != null ? new JSONArray(new String[]{ address.getFeatureName()} ) : new JSONArray());
70
+ placemark.put(
71
+ "areasOfInterest",
72
+ address.getFeatureName() != null ? new JSONArray(new String[] { address.getFeatureName() }) : new JSONArray()
73
+ );
73
74
 
74
75
  resultObj.put(placemark);
75
76
  }
@@ -79,8 +80,7 @@ public class NativeGeocoder {
79
80
  } else {
80
81
  call.reject("Cannot get an address.");
81
82
  }
82
- }
83
- catch (Exception e) {
83
+ } catch (Exception e) {
84
84
  String errorMsg = e.getMessage();
85
85
  if (e.getMessage().equals("grpc failed") && !isNetworkAvailable()) {
86
86
  errorMsg = "No Internet Access";
@@ -89,7 +89,6 @@ public class NativeGeocoder {
89
89
  }
90
90
  }
91
91
 
92
-
93
92
  /**
94
93
  * Forward geocode a given address to find coordinates
95
94
  * @param addressString String
@@ -137,12 +136,16 @@ public class NativeGeocoder {
137
136
  placemark.put("subLocality", address.getSubLocality() != null ? address.getSubLocality() : "");
138
137
  placemark.put("thoroughfare", address.getThoroughfare() != null ? address.getThoroughfare() : "");
139
138
  placemark.put("subThoroughfare", address.getSubThoroughfare() != null ? address.getSubThoroughfare() : "");
140
- placemark.put("areasOfInterest", address.getFeatureName() != null ? new JSONArray(new String[]{ address.getFeatureName() }) : new JSONArray());
139
+ placemark.put(
140
+ "areasOfInterest",
141
+ address.getFeatureName() != null
142
+ ? new JSONArray(new String[] { address.getFeatureName() })
143
+ : new JSONArray()
144
+ );
141
145
 
142
146
  resultObj.put(placemark);
143
147
  }
144
- }
145
- catch (RuntimeException e) {
148
+ } catch (RuntimeException e) {
146
149
  e.printStackTrace();
147
150
  }
148
151
  }
@@ -154,12 +157,10 @@ public class NativeGeocoder {
154
157
  ret.put("addresses", resultObj);
155
158
  call.resolve(ret);
156
159
  }
157
-
158
160
  } else {
159
161
  call.reject("Cannot find a location.");
160
162
  }
161
- }
162
- catch (Exception e) {
163
+ } catch (Exception e) {
163
164
  String errorMsg = e.getMessage();
164
165
  if (e.getMessage().equals("grpc failed") && !isNetworkAvailable()) {
165
166
  errorMsg = "No Internet Access";
@@ -173,8 +174,7 @@ public class NativeGeocoder {
173
174
  * @return boolean
174
175
  */
175
176
  private boolean isNetworkAvailable() {
176
- ConnectivityManager connectivityManager
177
- = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
177
+ ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
178
178
  NetworkInfo activeNetworkInfo = null;
179
179
  if (connectivityManager != null) {
180
180
  activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
@@ -221,12 +221,9 @@ public class NativeGeocoder {
221
221
  locale = Locale.forLanguageTag(geocoderOptions.defaultLocale);
222
222
  } else {
223
223
  String[] parts = geocoderOptions.defaultLocale.split("[-_]", -1);
224
- if (parts.length == 1)
225
- locale = new Locale(parts[0]);
226
- else if (parts.length == 2 || (parts.length == 3 && parts[2].startsWith("#")))
227
- locale = new Locale(parts[0], parts[1]);
228
- else
229
- locale = new Locale(parts[0], parts[1], parts[2]);
224
+ if (parts.length == 1) locale = new Locale(parts[0]); else if (
225
+ parts.length == 2 || (parts.length == 3 && parts[2].startsWith("#"))
226
+ ) locale = new Locale(parts[0], parts[1]); else locale = new Locale(parts[0], parts[1], parts[2]);
230
227
  }
231
228
  geocoder = new Geocoder(context.getApplicationContext(), locale);
232
229
  } else {
@@ -18,21 +18,22 @@ public class NativeGeocoderPlugin extends Plugin {
18
18
 
19
19
  @PluginMethod
20
20
  public void reverseGeocode(PluginCall call) {
21
- Double latitude = call.getDouble("latitude");
22
- Double longitude = call.getDouble("longitude");
23
- if (latitude == null || longitude == null) {
24
- call.reject("Missing latitude or longitude");
25
- return;
26
- }
27
- implementation.reverseGeocode(latitude, longitude, call);
21
+ Double latitude = call.getDouble("latitude");
22
+ Double longitude = call.getDouble("longitude");
23
+ if (latitude == null || longitude == null) {
24
+ call.reject("Missing latitude or longitude");
25
+ return;
26
+ }
27
+ implementation.reverseGeocode(latitude, longitude, call);
28
28
  }
29
+
29
30
  @PluginMethod
30
31
  public void forwardGeocode(PluginCall call) {
31
- String addressString = call.getString("addressString");
32
- if (addressString == null) {
33
- call.reject("Missing addressString");
34
- return;
35
- }
36
- implementation.forwardGeocode(addressString, call);
32
+ String addressString = call.getString("addressString");
33
+ if (addressString == null) {
34
+ call.reject("Missing addressString");
35
+ return;
36
+ }
37
+ implementation.forwardGeocode(addressString, call);
37
38
  }
38
39
  }
@@ -18,8 +18,8 @@ export interface ForwardOptions {
18
18
  */
19
19
  addressString: string;
20
20
  /**
21
- * Localise the results to the given locale.
22
- */
21
+ * Localise the results to the given locale.
22
+ */
23
23
  useLocale?: boolean;
24
24
  /**
25
25
  * locale is a string in the format of language_country, for example en_US.
@@ -44,8 +44,8 @@ export interface reverseOptions {
44
44
  */
45
45
  longitude: number;
46
46
  /**
47
- * Localise the results to the given locale.
48
- */
47
+ * Localise the results to the given locale.
48
+ */
49
49
  useLocale?: boolean;
50
50
  /**
51
51
  * locale is a string in the format of language_country, for example en_US.
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface Adress {\n latitude:\tnumber\n longitude:\tnumber\n countryCode:\tstring\n countryName:\tstring\n postalCode:\tstring\n administrativeArea:\tstring\n subAdministrativeArea:\tstring\n locality:\tstring\n subLocality:\tstring\n thoroughfare:\tstring\n subThoroughfare:\tstring\n areasOfInterest:\tstring[]\n}\n\nexport interface ForwardOptions {\n /**\n * address is a string of the address to be geocoded.\n */\n addressString:\tstring\n /**\n * Localise the results to the given locale.\n */\n useLocale?:\tboolean\n /**\n * locale is a string in the format of language_country, for example en_US.\n */\n defaultLocale?:\tstring\n /**\n * Max number of results to return.\n */\n maxResults?:\tnumber\n /**\n * Only used for web platform to use google api\n */\n apiKey?:\tstring\n}\nexport interface reverseOptions {\n /**\n * latitude is a number representing the latitude of the location.\n */\n latitude:\tnumber\n /**\n * longitude is a number representing the longitude of the location.\n */\n longitude:\tnumber\n /**\n * Localise the results to the given locale.\n */\n useLocale?:\tboolean\n /**\n * locale is a string in the format of language_country, for example en_US.\n */\n defaultLocale?:\tstring\n /**\n * Max number of results to return.\n */\n maxResults?:\tnumber\n /**\n * Only used for web platform to use google api\n */\n apiKey?:\tstring\n}\nexport interface NativeGeocoderPlugin {\n /**\n * Convert latitude and longitude to an address\n *\n * @param id The bundle id to delete (note, this is the bundle id, NOT the version name)\n * @returns {Promise<{addresses: Adress[]}>} an Promise with the list of addresses according to maxResults\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n reverseGeocode(options: reverseOptions): Promise<{ addresses:\tAdress[] }>;\n /**\n * Convert an address to latitude and longitude\n *\n * @returns {Promise<{addresses: Adress[]}>} an Promise with the list of addresses according to maxResults\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n forwardGeocode(options: ForwardOptions): Promise<{ addresses:\tAdress[] }>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface Adress {\n latitude: number;\n longitude: number;\n countryCode: string;\n countryName: string;\n postalCode: string;\n administrativeArea: string;\n subAdministrativeArea: string;\n locality: string;\n subLocality: string;\n thoroughfare: string;\n subThoroughfare: string;\n areasOfInterest: string[];\n}\n\nexport interface ForwardOptions {\n /**\n * address is a string of the address to be geocoded.\n */\n addressString: string;\n /**\n * Localise the results to the given locale.\n */\n useLocale?: boolean;\n /**\n * locale is a string in the format of language_country, for example en_US.\n */\n defaultLocale?: string;\n /**\n * Max number of results to return.\n */\n maxResults?: number;\n /**\n * Only used for web platform to use google api\n */\n apiKey?: string;\n}\nexport interface reverseOptions {\n /**\n * latitude is a number representing the latitude of the location.\n */\n latitude: number;\n /**\n * longitude is a number representing the longitude of the location.\n */\n longitude: number;\n /**\n * Localise the results to the given locale.\n */\n useLocale?: boolean;\n /**\n * locale is a string in the format of language_country, for example en_US.\n */\n defaultLocale?: string;\n /**\n * Max number of results to return.\n */\n maxResults?: number;\n /**\n * Only used for web platform to use google api\n */\n apiKey?: string;\n}\nexport interface NativeGeocoderPlugin {\n /**\n * Convert latitude and longitude to an address\n *\n * @param id The bundle id to delete (note, this is the bundle id, NOT the version name)\n * @returns {Promise<{addresses: Adress[]}>} an Promise with the list of addresses according to maxResults\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n reverseGeocode(options: reverseOptions): Promise<{ addresses: Adress[] }>;\n /**\n * Convert an address to latitude and longitude\n *\n * @returns {Promise<{addresses: Adress[]}>} an Promise with the list of addresses according to maxResults\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n forwardGeocode(options: ForwardOptions): Promise<{ addresses: Adress[] }>;\n}\n"]}
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { registerPlugin } from '@capacitor/core';
2
2
  const NativeGeocoder = registerPlugin('NativeGeocoder', {
3
- web: () => import('./web').then(m => new m.NativeGeocoderWeb()),
3
+ web: () => import('./web').then((m) => new m.NativeGeocoderWeb()),
4
4
  });
5
5
  export * from './definitions';
6
6
  export { NativeGeocoder };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,cAAc,GAAG,cAAc,CAAuB,gBAAgB,EAAE;IAC5E,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;CAChE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { NativeGeocoderPlugin } from './definitions';\n\nconst NativeGeocoder = registerPlugin<NativeGeocoderPlugin>('NativeGeocoder', {\n web: () => import('./web').then(m => new m.NativeGeocoderWeb()),\n});\n\nexport * from './definitions';\nexport { NativeGeocoder };\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,cAAc,GAAG,cAAc,CAAuB,gBAAgB,EAAE;IAC5E,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;CAClE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { NativeGeocoderPlugin } from './definitions';\n\nconst NativeGeocoder = registerPlugin<NativeGeocoderPlugin>('NativeGeocoder', {\n web: () => import('./web').then((m) => new m.NativeGeocoderWeb()),\n});\n\nexport * from './definitions';\nexport { NativeGeocoder };\n"]}
package/dist/esm/web.js CHANGED
@@ -1,6 +1,10 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
2
  const findAC = (address_components, type) => {
3
- return address_components.find(component => component.types.includes(type)) || { long_name: '', short_name: '', types: [] };
3
+ return (address_components.find((component) => component.types.includes(type)) || {
4
+ long_name: '',
5
+ short_name: '',
6
+ types: [],
7
+ });
4
8
  };
5
9
  export class NativeGeocoderWeb extends WebPlugin {
6
10
  async reverseGeocode(options) {
@@ -9,10 +13,11 @@ export class NativeGeocoderWeb extends WebPlugin {
9
13
  }
10
14
  const params = Object.assign(Object.assign({ latlng: `${options.latitude},${options.longitude}`, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });
11
15
  return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)
12
- .then(response => response.json())
16
+ .then((response) => response.json())
13
17
  .then((data) => {
14
18
  return {
15
- addresses: data.results.map((result) => {
19
+ addresses: data.results
20
+ .map((result) => {
16
21
  // transform the response in Adress[]
17
22
  // use the restul from google geocoder and transform it in Adress
18
23
  return {
@@ -29,21 +34,22 @@ export class NativeGeocoderWeb extends WebPlugin {
29
34
  subThoroughfare: findAC(result.address_components, 'street_number').long_name,
30
35
  areasOfInterest: [],
31
36
  };
32
- }).slice(0, options.maxResults || 1)
37
+ })
38
+ .slice(0, options.maxResults || 1),
33
39
  };
34
40
  });
35
41
  }
36
- ;
37
42
  async forwardGeocode(options) {
38
43
  if (!options.apiKey) {
39
44
  throw new Error('apiKey is required for web');
40
45
  }
41
46
  const params = Object.assign(Object.assign({ address: options.addressString, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });
42
47
  return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)
43
- .then(response => response.json())
48
+ .then((response) => response.json())
44
49
  .then((data) => {
45
50
  return {
46
- addresses: data.results.map((result) => {
51
+ addresses: data.results
52
+ .map((result) => {
47
53
  // transform the response in Adress[]
48
54
  // use the restul from google geocoder and transform it in Adress
49
55
  return {
@@ -60,10 +66,10 @@ export class NativeGeocoderWeb extends WebPlugin {
60
66
  subThoroughfare: findAC(result.address_components, 'street_number').long_name,
61
67
  areasOfInterest: [],
62
68
  };
63
- }).slice(0, options.maxResults || 1)
69
+ })
70
+ .slice(0, options.maxResults || 1),
64
71
  };
65
72
  });
66
73
  }
67
- ;
68
74
  }
69
75
  //# sourceMappingURL=web.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC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,CAAC,SAAS;wBAC7E,eAAe,EAAE,EAAE;qBACpB,CAAA;gBACH,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC;aACrC,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAAA,CAAC;CACP","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { NativeGeocoderPlugin, reverseOptions, ForwardOptions, Adress } from './definitions';\n\ninterface AddressComponent {\n long_name: string;\n short_name: string;\n types: string[];\n}\ninterface GeocoderResult {\n address_components: AddressComponent[];\n formatted_address: string;\n geometry: {\n location: {\n lat: number;\n lng: number;\n };\n location_type: string;\n viewport: {\n northeast: {\n lat: number;\n lng: number;\n };\n southwest: {\n lat: number;\n lng: number;\n };\n };\n };\n}\ninterface GeocoderPayload {\n plus_code: {\n compound_code: string, \n global_code: string\n }\n results: GeocoderResult[];\n}\n\nconst findAC = (address_components: AddressComponent[], type: string): AddressComponent => {\n return address_components.find(component => component.types.includes(type)) || { long_name: '', short_name: '', types: [] };\n}\nexport class NativeGeocoderWeb\n extends WebPlugin\n implements NativeGeocoderPlugin {\n async reverseGeocode(options: reverseOptions): Promise<{ addresses:\tAdress[] }> {\n if (!options.apiKey) {\n throw new Error('apiKey is required for web');\n }\n const params = {\n latlng: `${options.latitude},${options.longitude}`,\n key: options.apiKey,\n ...(options.defaultLocale && {language: options.defaultLocale}),\n result_type: 'street_address',\n }\n return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)\n .then(response => response.json())\n .then((data: GeocoderPayload): { addresses:\tAdress[] } => {\n return { \n addresses: data.results.map((result: GeocoderResult): Adress => {\n // transform the response in Adress[]\n // use the restul from google geocoder and transform it in Adress\n\n return {\n latitude: result.geometry.location.lat,\n longitude: result.geometry.location.lng,\n countryCode: findAC(result.address_components, 'country').short_name,\n countryName: findAC(result.address_components, 'country').long_name,\n postalCode: findAC(result.address_components, 'postal_code').long_name,\n administrativeArea: findAC(result.address_components, 'administrative_area_level_1').long_name,\n subAdministrativeArea: findAC(result.address_components, 'administrative_area_level_2').long_name,\n locality: findAC(result.address_components, 'locality').long_name,\n subLocality: findAC(result.address_components, 'sublocality').long_name,\n thoroughfare: findAC(result.address_components, 'route').long_name,\n subThoroughfare: findAC(result.address_components, 'street_number').long_name,\n areasOfInterest: [],\n }\n }).slice(0, options.maxResults || 1)\n }\n });\n };\n async forwardGeocode(options: ForwardOptions): Promise<{ addresses:\tAdress[] }> {\n if (!options.apiKey) {\n throw new Error('apiKey is required for web');\n }\n const params = {\n address: options.addressString,\n key: options.apiKey,\n ...(options.defaultLocale && {language: options.defaultLocale}),\n result_type: 'street_address',\n }\n return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)\n .then(response => response.json())\n .then((data: GeocoderPayload): { addresses:\tAdress[] } => {\n\n return { \n addresses: data.results.map((result: GeocoderResult): Adress => {\n // transform the response in Adress[]\n // use the restul from google geocoder and transform it in Adress\n return {\n latitude: result.geometry.location.lat,\n longitude: result.geometry.location.lng,\n countryCode: findAC(result.address_components, 'country').short_name,\n countryName: findAC(result.address_components, 'country').long_name,\n postalCode: findAC(result.address_components, 'postal_code').long_name,\n administrativeArea: findAC(result.address_components, 'administrative_area_level_1').long_name,\n subAdministrativeArea: findAC(result.address_components, 'administrative_area_level_2').long_name,\n locality: findAC(result.address_components, 'locality').long_name,\n subLocality: findAC(result.address_components, 'sublocality').long_name,\n thoroughfare: findAC(result.address_components, 'route').long_name,\n subThoroughfare: findAC(result.address_components, 'street_number').long_name,\n areasOfInterest: [],\n }\n }).slice(0, options.maxResults || 1)\n }\n })\n };\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAsC5C,MAAM,MAAM,GAAG,CAAC,kBAAsC,EAAE,IAAY,EAAoB,EAAE;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BACJ,CAAC,CAAC;qBACD,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC;aACrC,CAAC;QACJ,CAAC,CAAC,CAAC;IACP,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { NativeGeocoderPlugin, reverseOptions, ForwardOptions, Adress } from './definitions';\n\ninterface AddressComponent {\n long_name: string;\n short_name: string;\n types: string[];\n}\ninterface GeocoderResult {\n address_components: AddressComponent[];\n formatted_address: string;\n geometry: {\n location: {\n lat: number;\n lng: number;\n };\n location_type: string;\n viewport: {\n northeast: {\n lat: number;\n lng: number;\n };\n southwest: {\n lat: number;\n lng: number;\n };\n };\n };\n}\ninterface GeocoderPayload {\n plus_code: {\n compound_code: string;\n global_code: string;\n };\n results: GeocoderResult[];\n}\n\nconst findAC = (address_components: AddressComponent[], type: string): AddressComponent => {\n return (\n address_components.find((component) => component.types.includes(type)) || {\n long_name: '',\n short_name: '',\n types: [],\n }\n );\n};\nexport class NativeGeocoderWeb extends WebPlugin implements NativeGeocoderPlugin {\n async reverseGeocode(options: reverseOptions): Promise<{ addresses: Adress[] }> {\n if (!options.apiKey) {\n throw new Error('apiKey is required for web');\n }\n const params = {\n latlng: `${options.latitude},${options.longitude}`,\n key: options.apiKey,\n ...(options.defaultLocale && { language: options.defaultLocale }),\n result_type: 'street_address',\n };\n return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)\n .then((response) => response.json())\n .then((data: GeocoderPayload): { addresses: Adress[] } => {\n return {\n addresses: data.results\n .map((result: GeocoderResult): Adress => {\n // transform the response in Adress[]\n // use the restul from google geocoder and transform it in Adress\n\n return {\n latitude: result.geometry.location.lat,\n longitude: result.geometry.location.lng,\n countryCode: findAC(result.address_components, 'country').short_name,\n countryName: findAC(result.address_components, 'country').long_name,\n postalCode: findAC(result.address_components, 'postal_code').long_name,\n administrativeArea: findAC(result.address_components, 'administrative_area_level_1').long_name,\n subAdministrativeArea: findAC(result.address_components, 'administrative_area_level_2').long_name,\n locality: findAC(result.address_components, 'locality').long_name,\n subLocality: findAC(result.address_components, 'sublocality').long_name,\n thoroughfare: findAC(result.address_components, 'route').long_name,\n subThoroughfare: findAC(result.address_components, 'street_number').long_name,\n areasOfInterest: [],\n };\n })\n .slice(0, options.maxResults || 1),\n };\n });\n }\n async forwardGeocode(options: ForwardOptions): Promise<{ addresses: Adress[] }> {\n if (!options.apiKey) {\n throw new Error('apiKey is required for web');\n }\n const params = {\n address: options.addressString,\n key: options.apiKey,\n ...(options.defaultLocale && { language: options.defaultLocale }),\n result_type: 'street_address',\n };\n return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)\n .then((response) => response.json())\n .then((data: GeocoderPayload): { addresses: Adress[] } => {\n return {\n addresses: data.results\n .map((result: GeocoderResult): Adress => {\n // transform the response in Adress[]\n // use the restul from google geocoder and transform it in Adress\n return {\n latitude: result.geometry.location.lat,\n longitude: result.geometry.location.lng,\n countryCode: findAC(result.address_components, 'country').short_name,\n countryName: findAC(result.address_components, 'country').long_name,\n postalCode: findAC(result.address_components, 'postal_code').long_name,\n administrativeArea: findAC(result.address_components, 'administrative_area_level_1').long_name,\n subAdministrativeArea: findAC(result.address_components, 'administrative_area_level_2').long_name,\n locality: findAC(result.address_components, 'locality').long_name,\n subLocality: findAC(result.address_components, 'sublocality').long_name,\n thoroughfare: findAC(result.address_components, 'route').long_name,\n subThoroughfare: findAC(result.address_components, 'street_number').long_name,\n areasOfInterest: [],\n };\n })\n .slice(0, options.maxResults || 1),\n };\n });\n }\n}\n"]}
@@ -1,15 +1,17 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var core = require('@capacitor/core');
6
4
 
7
5
  const NativeGeocoder = core.registerPlugin('NativeGeocoder', {
8
- web: () => Promise.resolve().then(function () { return web; }).then(m => new m.NativeGeocoderWeb()),
6
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.NativeGeocoderWeb()),
9
7
  });
10
8
 
11
9
  const findAC = (address_components, type) => {
12
- return address_components.find(component => component.types.includes(type)) || { long_name: '', short_name: '', types: [] };
10
+ return (address_components.find((component) => component.types.includes(type)) || {
11
+ long_name: '',
12
+ short_name: '',
13
+ types: [],
14
+ });
13
15
  };
14
16
  class NativeGeocoderWeb extends core.WebPlugin {
15
17
  async reverseGeocode(options) {
@@ -18,10 +20,11 @@ class NativeGeocoderWeb extends core.WebPlugin {
18
20
  }
19
21
  const params = Object.assign(Object.assign({ latlng: `${options.latitude},${options.longitude}`, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });
20
22
  return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)
21
- .then(response => response.json())
23
+ .then((response) => response.json())
22
24
  .then((data) => {
23
25
  return {
24
- addresses: data.results.map((result) => {
26
+ addresses: data.results
27
+ .map((result) => {
25
28
  // transform the response in Adress[]
26
29
  // use the restul from google geocoder and transform it in Adress
27
30
  return {
@@ -38,21 +41,22 @@ class NativeGeocoderWeb extends core.WebPlugin {
38
41
  subThoroughfare: findAC(result.address_components, 'street_number').long_name,
39
42
  areasOfInterest: [],
40
43
  };
41
- }).slice(0, options.maxResults || 1)
44
+ })
45
+ .slice(0, options.maxResults || 1),
42
46
  };
43
47
  });
44
48
  }
45
- ;
46
49
  async forwardGeocode(options) {
47
50
  if (!options.apiKey) {
48
51
  throw new Error('apiKey is required for web');
49
52
  }
50
53
  const params = Object.assign(Object.assign({ address: options.addressString, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });
51
54
  return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)
52
- .then(response => response.json())
55
+ .then((response) => response.json())
53
56
  .then((data) => {
54
57
  return {
55
- addresses: data.results.map((result) => {
58
+ addresses: data.results
59
+ .map((result) => {
56
60
  // transform the response in Adress[]
57
61
  // use the restul from google geocoder and transform it in Adress
58
62
  return {
@@ -69,11 +73,11 @@ class NativeGeocoderWeb extends core.WebPlugin {
69
73
  subThoroughfare: findAC(result.address_components, 'street_number').long_name,
70
74
  areasOfInterest: [],
71
75
  };
72
- }).slice(0, options.maxResults || 1)
76
+ })
77
+ .slice(0, options.maxResults || 1),
73
78
  };
74
79
  });
75
80
  }
76
- ;
77
81
  }
78
82
 
79
83
  var web = /*#__PURE__*/Object.freeze({
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst NativeGeocoder = registerPlugin('NativeGeocoder', {\n web: () => import('./web').then(m => new m.NativeGeocoderWeb()),\n});\nexport * from './definitions';\nexport { NativeGeocoder };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nconst findAC = (address_components, type) => {\n return address_components.find(component => component.types.includes(type)) || { long_name: '', short_name: '', types: [] };\n};\nexport class NativeGeocoderWeb extends WebPlugin {\n async reverseGeocode(options) {\n if (!options.apiKey) {\n throw new Error('apiKey is required for web');\n }\n const params = Object.assign(Object.assign({ latlng: `${options.latitude},${options.longitude}`, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });\n return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)\n .then(response => response.json())\n .then((data) => {\n return {\n addresses: data.results.map((result) => {\n // transform the response in Adress[]\n // use the restul from google geocoder and transform it in Adress\n return {\n latitude: result.geometry.location.lat,\n longitude: result.geometry.location.lng,\n countryCode: findAC(result.address_components, 'country').short_name,\n countryName: findAC(result.address_components, 'country').long_name,\n postalCode: findAC(result.address_components, 'postal_code').long_name,\n administrativeArea: findAC(result.address_components, 'administrative_area_level_1').long_name,\n subAdministrativeArea: findAC(result.address_components, 'administrative_area_level_2').long_name,\n locality: findAC(result.address_components, 'locality').long_name,\n subLocality: findAC(result.address_components, 'sublocality').long_name,\n thoroughfare: findAC(result.address_components, 'route').long_name,\n subThoroughfare: findAC(result.address_components, 'street_number').long_name,\n areasOfInterest: [],\n };\n }).slice(0, options.maxResults || 1)\n };\n });\n }\n ;\n async forwardGeocode(options) {\n if (!options.apiKey) {\n throw new Error('apiKey is required for web');\n }\n const params = Object.assign(Object.assign({ address: options.addressString, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });\n return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)\n .then(response => response.json())\n .then((data) => {\n return {\n addresses: data.results.map((result) => {\n // transform the response in Adress[]\n // use the restul from google geocoder and transform it in Adress\n return {\n latitude: result.geometry.location.lat,\n longitude: result.geometry.location.lng,\n countryCode: findAC(result.address_components, 'country').short_name,\n countryName: findAC(result.address_components, 'country').long_name,\n postalCode: findAC(result.address_components, 'postal_code').long_name,\n administrativeArea: findAC(result.address_components, 'administrative_area_level_1').long_name,\n subAdministrativeArea: findAC(result.address_components, 'administrative_area_level_2').long_name,\n locality: findAC(result.address_components, 'locality').long_name,\n subLocality: findAC(result.address_components, 'sublocality').long_name,\n thoroughfare: findAC(result.address_components, 'route').long_name,\n subThoroughfare: findAC(result.address_components, 'street_number').long_name,\n areasOfInterest: [],\n };\n }).slice(0, options.maxResults || 1)\n };\n });\n }\n ;\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,cAAc,GAAGA,mBAAc,CAAC,gBAAgB,EAAE;AACxD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;AACnE,CAAC;;ACFD,MAAM,MAAM,GAAG,CAAC,kBAAkB,EAAE,IAAI,KAAK;AAC7C,IAAI,OAAO,kBAAkB,CAAC,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC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wBAAwB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC,SAAS;AAC/F,wBAAwB,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC,SAAS;AAC1F,wBAAwB,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAC,SAAS;AACrG,wBAAwB,eAAe,EAAE,EAAE;AAC3C,qBAAqB,CAAC;AACtB,iBAAiB,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC;AACpD,aAAa,CAAC;AACd,SAAS,CAAC,CAAC;AACX,KAAK;AACL;AACA;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst NativeGeocoder = registerPlugin('NativeGeocoder', {\n web: () => import('./web').then((m) => new m.NativeGeocoderWeb()),\n});\nexport * from './definitions';\nexport { NativeGeocoder };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nconst findAC = (address_components, type) => {\n return (address_components.find((component) => component.types.includes(type)) || {\n long_name: '',\n short_name: '',\n types: [],\n });\n};\nexport class NativeGeocoderWeb extends WebPlugin {\n async reverseGeocode(options) {\n if (!options.apiKey) {\n throw new Error('apiKey is required for web');\n }\n const params = Object.assign(Object.assign({ latlng: `${options.latitude},${options.longitude}`, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });\n return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)\n .then((response) => response.json())\n .then((data) => {\n return {\n addresses: data.results\n .map((result) => {\n // transform the response in Adress[]\n // use the restul from google geocoder and transform it in Adress\n return {\n latitude: result.geometry.location.lat,\n longitude: result.geometry.location.lng,\n countryCode: findAC(result.address_components, 'country').short_name,\n countryName: findAC(result.address_components, 'country').long_name,\n postalCode: findAC(result.address_components, 'postal_code').long_name,\n administrativeArea: findAC(result.address_components, 'administrative_area_level_1').long_name,\n subAdministrativeArea: findAC(result.address_components, 'administrative_area_level_2').long_name,\n locality: findAC(result.address_components, 'locality').long_name,\n subLocality: findAC(result.address_components, 'sublocality').long_name,\n thoroughfare: findAC(result.address_components, 'route').long_name,\n subThoroughfare: findAC(result.address_components, 'street_number').long_name,\n areasOfInterest: [],\n };\n })\n .slice(0, options.maxResults || 1),\n };\n });\n }\n async forwardGeocode(options) {\n if (!options.apiKey) {\n throw new Error('apiKey is required for web');\n }\n const params = Object.assign(Object.assign({ address: options.addressString, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });\n return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)\n .then((response) => response.json())\n .then((data) => {\n return {\n addresses: data.results\n .map((result) => {\n // transform the response in Adress[]\n // use the restul from google geocoder and transform it in Adress\n return {\n latitude: result.geometry.location.lat,\n longitude: result.geometry.location.lng,\n countryCode: findAC(result.address_components, 'country').short_name,\n countryName: findAC(result.address_components, 'country').long_name,\n postalCode: findAC(result.address_components, 'postal_code').long_name,\n administrativeArea: findAC(result.address_components, 'administrative_area_level_1').long_name,\n subAdministrativeArea: findAC(result.address_components, 'administrative_area_level_2').long_name,\n locality: findAC(result.address_components, 'locality').long_name,\n subLocality: findAC(result.address_components, 'sublocality').long_name,\n thoroughfare: findAC(result.address_components, 'route').long_name,\n subThoroughfare: findAC(result.address_components, 'street_number').long_name,\n areasOfInterest: [],\n };\n })\n .slice(0, options.maxResults || 1),\n };\n });\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,cAAc,GAAGA,mBAAc,CAAC,gBAAgB,EAAE;AACxD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,i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AE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,6BAA6B,CAAC,CAAC,SAAS;AACtH,wBAAwB,qBAAqB,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,6BAA6B,CAAC,CAAC,SAAS;AACzH,wBAAwB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC,SAAS;AACzF,wBAAwB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC,SAAS;AAC/F,wBAAwB,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC,SAAS;AAC1F,wBAAwB,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAC,SAAS;AACrG,wBAAwB,eAAe,EAAE,EAAE;AAC3C,qBAAqB,CAAC;AACtB,iBAAiB,CAAC;AAClB,qBAAqB,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC;AACtD,aAAa,CAAC;AACd,SAAS,CAAC,CAAC;AACX,KAAK;AACL;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -2,11 +2,15 @@ var capacitorNativeGeocoder = (function (exports, core) {
2
2
  'use strict';
3
3
 
4
4
  const NativeGeocoder = core.registerPlugin('NativeGeocoder', {
5
- web: () => Promise.resolve().then(function () { return web; }).then(m => new m.NativeGeocoderWeb()),
5
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.NativeGeocoderWeb()),
6
6
  });
7
7
 
8
8
  const findAC = (address_components, type) => {
9
- return address_components.find(component => component.types.includes(type)) || { long_name: '', short_name: '', types: [] };
9
+ return (address_components.find((component) => component.types.includes(type)) || {
10
+ long_name: '',
11
+ short_name: '',
12
+ types: [],
13
+ });
10
14
  };
11
15
  class NativeGeocoderWeb extends core.WebPlugin {
12
16
  async reverseGeocode(options) {
@@ -15,10 +19,11 @@ var capacitorNativeGeocoder = (function (exports, core) {
15
19
  }
16
20
  const params = Object.assign(Object.assign({ latlng: `${options.latitude},${options.longitude}`, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });
17
21
  return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)
18
- .then(response => response.json())
22
+ .then((response) => response.json())
19
23
  .then((data) => {
20
24
  return {
21
- addresses: data.results.map((result) => {
25
+ addresses: data.results
26
+ .map((result) => {
22
27
  // transform the response in Adress[]
23
28
  // use the restul from google geocoder and transform it in Adress
24
29
  return {
@@ -35,21 +40,22 @@ var capacitorNativeGeocoder = (function (exports, core) {
35
40
  subThoroughfare: findAC(result.address_components, 'street_number').long_name,
36
41
  areasOfInterest: [],
37
42
  };
38
- }).slice(0, options.maxResults || 1)
43
+ })
44
+ .slice(0, options.maxResults || 1),
39
45
  };
40
46
  });
41
47
  }
42
- ;
43
48
  async forwardGeocode(options) {
44
49
  if (!options.apiKey) {
45
50
  throw new Error('apiKey is required for web');
46
51
  }
47
52
  const params = Object.assign(Object.assign({ address: options.addressString, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });
48
53
  return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)
49
- .then(response => response.json())
54
+ .then((response) => response.json())
50
55
  .then((data) => {
51
56
  return {
52
- addresses: data.results.map((result) => {
57
+ addresses: data.results
58
+ .map((result) => {
53
59
  // transform the response in Adress[]
54
60
  // use the restul from google geocoder and transform it in Adress
55
61
  return {
@@ -66,11 +72,11 @@ var capacitorNativeGeocoder = (function (exports, core) {
66
72
  subThoroughfare: findAC(result.address_components, 'street_number').long_name,
67
73
  areasOfInterest: [],
68
74
  };
69
- }).slice(0, options.maxResults || 1)
75
+ })
76
+ .slice(0, options.maxResults || 1),
70
77
  };
71
78
  });
72
79
  }
73
- ;
74
80
  }
75
81
 
76
82
  var web = /*#__PURE__*/Object.freeze({
@@ -80,8 +86,6 @@ var capacitorNativeGeocoder = (function (exports, core) {
80
86
 
81
87
  exports.NativeGeocoder = NativeGeocoder;
82
88
 
83
- Object.defineProperty(exports, '__esModule', { value: true });
84
-
85
89
  return exports;
86
90
 
87
91
  })({}, capacitorExports);
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst NativeGeocoder = registerPlugin('NativeGeocoder', {\n web: () => import('./web').then(m => new m.NativeGeocoderWeb()),\n});\nexport * from './definitions';\nexport { NativeGeocoder };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nconst findAC = (address_components, type) => {\n return address_components.find(component => component.types.includes(type)) || { long_name: '', short_name: '', types: [] };\n};\nexport class NativeGeocoderWeb extends WebPlugin {\n async reverseGeocode(options) {\n if (!options.apiKey) {\n throw new Error('apiKey is required for web');\n }\n const params = Object.assign(Object.assign({ latlng: `${options.latitude},${options.longitude}`, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });\n return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)\n .then(response => response.json())\n .then((data) => {\n return {\n addresses: data.results.map((result) => {\n // transform the response in Adress[]\n // use the restul from google geocoder and transform it in Adress\n return {\n latitude: result.geometry.location.lat,\n longitude: result.geometry.location.lng,\n countryCode: findAC(result.address_components, 'country').short_name,\n countryName: findAC(result.address_components, 'country').long_name,\n postalCode: findAC(result.address_components, 'postal_code').long_name,\n administrativeArea: findAC(result.address_components, 'administrative_area_level_1').long_name,\n subAdministrativeArea: findAC(result.address_components, 'administrative_area_level_2').long_name,\n locality: findAC(result.address_components, 'locality').long_name,\n subLocality: findAC(result.address_components, 'sublocality').long_name,\n thoroughfare: findAC(result.address_components, 'route').long_name,\n subThoroughfare: findAC(result.address_components, 'street_number').long_name,\n areasOfInterest: [],\n };\n }).slice(0, options.maxResults || 1)\n };\n });\n }\n ;\n async forwardGeocode(options) {\n if (!options.apiKey) {\n throw new Error('apiKey is required for web');\n }\n const params = Object.assign(Object.assign({ address: options.addressString, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });\n return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)\n .then(response => response.json())\n .then((data) => {\n return {\n addresses: data.results.map((result) => {\n // transform the response in Adress[]\n // use the restul from google geocoder and transform it in Adress\n return {\n latitude: result.geometry.location.lat,\n longitude: result.geometry.location.lng,\n countryCode: findAC(result.address_components, 'country').short_name,\n countryName: findAC(result.address_components, 'country').long_name,\n postalCode: findAC(result.address_components, 'postal_code').long_name,\n administrativeArea: findAC(result.address_components, 'administrative_area_level_1').long_name,\n subAdministrativeArea: findAC(result.address_components, 'administrative_area_level_2').long_name,\n locality: findAC(result.address_components, 'locality').long_name,\n subLocality: findAC(result.address_components, 'sublocality').long_name,\n thoroughfare: findAC(result.address_components, 'route').long_name,\n subThoroughfare: findAC(result.address_components, 'street_number').long_name,\n areasOfInterest: [],\n };\n }).slice(0, options.maxResults || 1)\n };\n });\n }\n ;\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,cAAc,GAAGA,mBAAc,CAAC,gBAAgB,EAAE;IACxD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;IACnE,CAAC;;ICFD,MAAM,MAAM,GAAG,CAAC,kBAAkB,EAAE,IAAI,KAAK;IAC7C,IAAI,OAAO,kBAAkB,CAAC,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAChI,CAAC,CAAC;I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CAAC,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC,SAAS;IAC1F,wBAAwB,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAC,SAAS;IACrG,wBAAwB,eAAe,EAAE,EAAE;IAC3C,qBAAqB,CAAC;IACtB,iBAAiB,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC;IACpD,aAAa,CAAC;IACd,SAAS,CAAC,CAAC;IACX,KAAK;IACL;IACA;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst NativeGeocoder = registerPlugin('NativeGeocoder', {\n web: () => import('./web').then((m) => new m.NativeGeocoderWeb()),\n});\nexport * from './definitions';\nexport { NativeGeocoder };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nconst findAC = (address_components, type) => {\n return (address_components.find((component) => component.types.includes(type)) || {\n long_name: '',\n short_name: '',\n types: [],\n });\n};\nexport class NativeGeocoderWeb extends WebPlugin {\n async reverseGeocode(options) {\n if (!options.apiKey) {\n throw new Error('apiKey is required for web');\n }\n const params = Object.assign(Object.assign({ latlng: `${options.latitude},${options.longitude}`, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });\n return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)\n .then((response) => response.json())\n .then((data) => {\n return {\n addresses: data.results\n .map((result) => {\n // transform the response in Adress[]\n // use the restul from google geocoder and transform it in Adress\n return {\n latitude: result.geometry.location.lat,\n longitude: result.geometry.location.lng,\n countryCode: findAC(result.address_components, 'country').short_name,\n countryName: findAC(result.address_components, 'country').long_name,\n postalCode: findAC(result.address_components, 'postal_code').long_name,\n administrativeArea: findAC(result.address_components, 'administrative_area_level_1').long_name,\n subAdministrativeArea: findAC(result.address_components, 'administrative_area_level_2').long_name,\n locality: findAC(result.address_components, 'locality').long_name,\n subLocality: findAC(result.address_components, 'sublocality').long_name,\n thoroughfare: findAC(result.address_components, 'route').long_name,\n subThoroughfare: findAC(result.address_components, 'street_number').long_name,\n areasOfInterest: [],\n };\n })\n .slice(0, options.maxResults || 1),\n };\n });\n }\n async forwardGeocode(options) {\n if (!options.apiKey) {\n throw new Error('apiKey is required for web');\n }\n const params = Object.assign(Object.assign({ address: options.addressString, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });\n return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)\n .then((response) => response.json())\n .then((data) => {\n return {\n addresses: data.results\n .map((result) => {\n // transform the response in Adress[]\n // use the restul from google geocoder and transform it in Adress\n return {\n latitude: result.geometry.location.lat,\n longitude: result.geometry.location.lng,\n countryCode: findAC(result.address_components, 'country').short_name,\n countryName: findAC(result.address_components, 'country').long_name,\n postalCode: findAC(result.address_components, 'postal_code').long_name,\n administrativeArea: findAC(result.address_components, 'administrative_area_level_1').long_name,\n subAdministrativeArea: findAC(result.address_components, 'administrative_area_level_2').long_name,\n locality: findAC(result.address_components, 'locality').long_name,\n subLocality: findAC(result.address_components, 'sublocality').long_name,\n thoroughfare: findAC(result.address_components, 'route').long_name,\n subThoroughfare: findAC(result.address_components, 'street_number').long_name,\n areasOfInterest: [],\n };\n })\n .slice(0, options.maxResults || 1),\n };\n });\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,cAAc,GAAGA,mBAAc,CAAC,gBAAgB,EAAE;IACxD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;IACrE,CAAC;;ICFD,MAAM,MAAM,GAAG,CAAC,kBAAkB,EAAE,IAAI,KAAK;IAC7C,IAAI,QAAQ,kBA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M,CAAC,kBAAkB,EAAE,6BAA6B,CAAC,CAAC,SAAS;IACzH,wBAAwB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC,SAAS;IACzF,wBAAwB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC,SAAS;IAC/F,wBAAwB,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC,SAAS;IAC1F,wBAAwB,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAC,SAAS;IACrG,wBAAwB,eAAe,EAAE,EAAE;IAC3C,qBAAqB,CAAC;IACtB,iBAAiB,CAAC;IAClB,qBAAqB,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC;IACtD,aAAa,CAAC;IACd,SAAS,CAAC,CAAC;IACX,KAAK;IACL;;;;;;;;;;;;;;;"}
@@ -19,11 +19,11 @@ struct NativeGeocoderOptions: Decodable {
19
19
  private static let MAX_RESULTS_COUNT = 5
20
20
 
21
21
  func reverseGeocode(latitude: Double, longitude: Double, call: CAPPluginCall) {
22
- if (CLGeocoder().isGeocoding) {
22
+ if CLGeocoder().isGeocoding {
23
23
  call.reject("Geocoder is busy. Please try again later.")
24
24
  return
25
25
  }
26
-
26
+
27
27
  let location = CLLocation(latitude: latitude, longitude: longitude)
28
28
  var options = NativeGeocoderOptions(useLocale: true, defaultLocale: nil, maxResults: 1)
29
29
  options.useLocale = call.getBool("useLocale") ?? true
@@ -38,15 +38,15 @@ struct NativeGeocoderOptions: Decodable {
38
38
  }
39
39
  })
40
40
  }
41
-
41
+
42
42
  private func reverseGeocodeLocationHandler(_ location: CLLocation, options: NativeGeocoderOptions, completionHandler: @escaping ReverseGeocodeCompletionHandler) {
43
43
  let geocoderOptions = getNativeGeocoderOptions(from: options)
44
-
44
+
45
45
  if #available(iOS 11, *) {
46
46
  var locale: Locale?
47
47
  if let defaultLocaleString = geocoderOptions.defaultLocale {
48
48
  locale = Locale.init(identifier: defaultLocaleString)
49
- } else if (geocoderOptions.useLocale == false) {
49
+ } else if geocoderOptions.useLocale == false {
50
50
  locale = Locale.init(identifier: "en_US")
51
51
  }
52
52
 
@@ -64,42 +64,40 @@ struct NativeGeocoderOptions: Decodable {
64
64
  })
65
65
  }
66
66
  }
67
-
67
+
68
68
  private func createReverseGeocodeResult(_ placemarks: [CLPlacemark]?, _ error: Error?, maxResults: Int, completionHandler: @escaping ReverseGeocodeCompletionHandler) {
69
69
  guard error == nil else {
70
70
  completionHandler(nil, NativeGeocoderError(message: "CLGeocoder:reverseGeocodeLocation Error"))
71
71
  return
72
72
  }
73
-
73
+
74
74
  if let placemarks = placemarks {
75
75
  let maxResultObjects = placemarks.count >= maxResults ? maxResults : placemarks.count
76
76
  var resultObj = [JSObject]()
77
-
77
+
78
78
  for i in 0..<maxResultObjects {
79
79
  let placemark = makePosition(placemarks[i])
80
80
  resultObj.append(placemark)
81
81
  }
82
-
82
+
83
83
  completionHandler(resultObj, nil)
84
- }
85
- else {
84
+ } else {
86
85
  completionHandler(nil, NativeGeocoderError(message: "Cannot get an address"))
87
86
  }
88
87
  }
89
-
90
-
88
+
91
89
  func forwardGeocode(address: String, call: CAPPluginCall) {
92
-
93
- if (CLGeocoder().isGeocoding) {
90
+
91
+ if CLGeocoder().isGeocoding {
94
92
  call.reject("Geocoder is busy. Please try again later.")
95
93
  return
96
94
  }
97
-
95
+
98
96
  var options = NativeGeocoderOptions(useLocale: true, defaultLocale: nil, maxResults: 1)
99
97
  options.useLocale = call.getBool("useLocale") ?? true
100
98
  options.defaultLocale = call.getString("defaultLocale")
101
99
  options.maxResults = call.getInt("maxResults") ?? 1
102
-
100
+
103
101
  forwardGeocodeHandler(address, options: options, completionHandler: { (resultObj, error) in
104
102
  if let error = error {
105
103
  call.reject(error.message)
@@ -108,18 +106,18 @@ struct NativeGeocoderOptions: Decodable {
108
106
  }
109
107
  })
110
108
  }
111
-
109
+
112
110
  func forwardGeocodeHandler(_ address: String, options: NativeGeocoderOptions, completionHandler: @escaping ForwardGeocodeCompletionHandler) {
113
111
  let geocoderOptions = getNativeGeocoderOptions(from: options)
114
-
112
+
115
113
  if #available(iOS 11, *) {
116
114
  var locale: Locale?
117
115
  if let defaultLocaleString = geocoderOptions.defaultLocale {
118
116
  locale = Locale.init(identifier: defaultLocaleString)
119
- } else if (geocoderOptions.useLocale == false) {
117
+ } else if geocoderOptions.useLocale == false {
120
118
  locale = Locale.init(identifier: "en_US")
121
119
  }
122
-
120
+
123
121
  CLGeocoder().geocodeAddressString(address, in: nil, preferredLocale: locale, completionHandler: { [weak self] (placemarks, error) in
124
122
  self?.createForwardGeocodeResult(placemarks, error, maxResults: geocoderOptions.maxResults, completionHandler: { (resultObj, error) in
125
123
  completionHandler(resultObj, error)
@@ -134,7 +132,7 @@ struct NativeGeocoderOptions: Decodable {
134
132
  })
135
133
  }
136
134
  }
137
-
135
+
138
136
  private func makePosition(_ placemark: CLPlacemark) -> JSObject {
139
137
  var ret = JSObject()
140
138
  ret["latitude"] = placemark.location?.coordinate.latitude ?? ""
@@ -157,36 +155,35 @@ struct NativeGeocoderOptions: Decodable {
157
155
  completionHandler(nil, NativeGeocoderError(message: "CLGeocoder:geocodeAddressString Error"))
158
156
  return
159
157
  }
160
-
158
+
161
159
  if let placemarks = placemarks {
162
160
  let maxResultObjects = placemarks.count >= maxResults ? maxResults : placemarks.count
163
161
  var resultObj = [JSObject]()
164
-
162
+
165
163
  for i in 0..<maxResultObjects {
166
164
  if let latitude = placemarks[i].location?.coordinate.latitude,
167
- let longitude = placemarks[i].location?.coordinate.longitude {
165
+ let longitude = placemarks[i].location?.coordinate.longitude {
168
166
  let placemark = makePosition(placemarks[i])
169
167
  resultObj.append(placemark)
170
168
  }
171
169
  }
172
-
173
- if (resultObj.count == 0) {
170
+
171
+ if resultObj.count == 0 {
174
172
  completionHandler(nil, NativeGeocoderError(message: "Cannot get latitude and/or longitude"))
175
173
  } else {
176
174
  completionHandler(resultObj, nil)
177
175
  }
178
- }
179
- else {
176
+ } else {
180
177
  completionHandler(nil, NativeGeocoderError(message: "Cannot find a location"))
181
178
  }
182
179
  }
183
-
180
+
184
181
  // MARK: - Helper
185
182
  private func getNativeGeocoderOptions(from options: NativeGeocoderOptions) -> NativeGeocoderOptions {
186
183
  var geocoderOptions = NativeGeocoderOptions()
187
184
  geocoderOptions.useLocale = options.useLocale
188
185
  geocoderOptions.defaultLocale = options.defaultLocale
189
- if (options.maxResults > 0) {
186
+ if options.maxResults > 0 {
190
187
  geocoderOptions.maxResults = options.maxResults > NativeGeocoder.MAX_RESULTS_COUNT ? NativeGeocoder.MAX_RESULTS_COUNT : options.maxResults
191
188
  } else {
192
189
  geocoderOptions.maxResults = 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/nativegeocoder",
3
- "version": "0.1.26",
3
+ "version": "0.1.29",
4
4
  "description": "Capacitor plugin for native forward and reverse geocoding",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -13,8 +13,6 @@
13
13
  "ios/Plugin/",
14
14
  "CapgoNativegeocoder.podspec"
15
15
  ],
16
- "author": "Martin Donadieu",
17
- "license": "MIT",
18
16
  "repository": {
19
17
  "type": "git",
20
18
  "url": "git+https://github.com/Cap-go/capacitor-nativegeocoder.git"
@@ -35,34 +33,42 @@
35
33
  "verify:android": "cd android && ./gradlew clean build test && cd ..",
36
34
  "verify:web": "npm run build",
37
35
  "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
38
- "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
36
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --autocorrect --format",
39
37
  "eslint": "eslint . --ext ts",
40
38
  "prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
41
39
  "swiftlint": "node-swiftlint",
42
40
  "docgen": "docgen --api NativeGeocoderPlugin --output-readme README.md --output-json dist/docs.json",
43
- "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
44
- "clean": "rimraf ./dist",
41
+ "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
42
+ "clean": "rimraf ./dist && cd android && ./gradlew clean && cd ..",
45
43
  "watch": "tsc --watch",
46
- "prepublishOnly": "npm run build"
44
+ "prepublishOnly": "npm run build",
45
+ "prepare": "husky install"
47
46
  },
47
+ "author": "Martin Donadieu <martindonadieu@gmail.com>",
48
+ "license": "MIT",
48
49
  "devDependencies": {
49
- "@capacitor/android": "^3.0.0",
50
- "@capacitor/core": "^3.0.0",
51
- "@capacitor/docgen": "^0.0.18",
52
- "@capacitor/ios": "^3.0.0",
50
+ "@capacitor/android": "^4.4.0",
51
+ "@capacitor/cli": "^4.4.0",
52
+ "@capacitor/core": "^4.4.0",
53
+ "@capacitor/docgen": "^0.2.0",
54
+ "@capacitor/ios": "^4.4.0",
53
55
  "@ionic/eslint-config": "^0.3.0",
54
- "@ionic/prettier-config": "^1.0.1",
56
+ "@ionic/prettier-config": "^2.0.0",
55
57
  "@ionic/swiftlint-config": "^1.1.2",
56
- "eslint": "^7.11.0",
57
- "prettier": "~2.2.0",
58
- "prettier-plugin-java": "~1.0.0",
58
+ "@typescript-eslint/eslint-plugin": "^5.42.1",
59
+ "@typescript-eslint/parser": "^5.42.1",
60
+ "eslint": "^8.27.0",
61
+ "eslint-plugin-import": "^2.26.0",
62
+ "husky": "^8.0.2",
63
+ "prettier": "^2.7.1",
64
+ "prettier-plugin-java": "^1.6.2",
59
65
  "rimraf": "^3.0.2",
60
- "rollup": "^2.32.0",
66
+ "rollup": "^3.2.5",
61
67
  "swiftlint": "^1.0.1",
62
- "typescript": "~4.0.3"
68
+ "typescript": "^4.8.4"
63
69
  },
64
70
  "peerDependencies": {
65
- "@capacitor/core": "^3.0.0 || ^4.0.0"
71
+ "@capacitor/core": "^4.0.0"
66
72
  },
67
73
  "prettier": "@ionic/prettier-config",
68
74
  "swiftlint": "@ionic/swiftlint-config",