@capgo/nativegeocoder 1.0.9 → 1.0.12

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.
package/README.md CHANGED
@@ -56,14 +56,14 @@ This API requires the following permissions be added to your `AndroidManifest.xm
56
56
  ### reverseGeocode(...)
57
57
 
58
58
  ```typescript
59
- reverseGeocode(options: reverseOptions) => any
59
+ reverseGeocode(options: ReverseOptions) => any
60
60
  ```
61
61
 
62
62
  Convert latitude and longitude to an address
63
63
 
64
64
  | Param | Type |
65
65
  | ------------- | --------------------------------------------------------- |
66
- | **`options`** | <code><a href="#reverseoptions">reverseOptions</a></code> |
66
+ | **`options`** | <code><a href="#reverseoptions">ReverseOptions</a></code> |
67
67
 
68
68
  **Returns:** <code>any</code>
69
69
 
@@ -94,7 +94,7 @@ Convert an address to latitude and longitude
94
94
  ### Interfaces
95
95
 
96
96
 
97
- #### reverseOptions
97
+ #### ReverseOptions
98
98
 
99
99
  | Prop | Type | Description |
100
100
  | ------------------- | -------------------- | ------------------------------------------------------------------------ |
@@ -106,7 +106,7 @@ Convert an address to latitude and longitude
106
106
  | **`apiKey`** | <code>string</code> | Only used for web platform to use google api |
107
107
 
108
108
 
109
- #### Adress
109
+ #### Address
110
110
 
111
111
  | Prop | Type |
112
112
  | --------------------------- | ------------------- |
@@ -11,7 +11,7 @@ buildscript {
11
11
  google()
12
12
  }
13
13
  dependencies {
14
- classpath 'com.android.tools.build:gradle:8.0.2'
14
+ classpath 'com.android.tools.build:gradle:8.1.0'
15
15
  }
16
16
  }
17
17
 
package/dist/docs.json CHANGED
@@ -7,12 +7,12 @@
7
7
  "methods": [
8
8
  {
9
9
  "name": "reverseGeocode",
10
- "signature": "(options: reverseOptions) => any",
10
+ "signature": "(options: ReverseOptions) => any",
11
11
  "parameters": [
12
12
  {
13
13
  "name": "options",
14
14
  "docs": "",
15
- "type": "reverseOptions"
15
+ "type": "ReverseOptions"
16
16
  }
17
17
  ],
18
18
  "returns": "any",
@@ -36,8 +36,8 @@
36
36
  ],
37
37
  "docs": "Convert latitude and longitude to an address",
38
38
  "complexTypes": [
39
- "reverseOptions",
40
- "Adress"
39
+ "ReverseOptions",
40
+ "Address"
41
41
  ],
42
42
  "slug": "reversegeocode"
43
43
  },
@@ -69,7 +69,7 @@
69
69
  "docs": "Convert an address to latitude and longitude",
70
70
  "complexTypes": [
71
71
  "ForwardOptions",
72
- "Adress"
72
+ "Address"
73
73
  ],
74
74
  "slug": "forwardgeocode"
75
75
  }
@@ -78,7 +78,7 @@
78
78
  },
79
79
  "interfaces": [
80
80
  {
81
- "name": "reverseOptions",
81
+ "name": "ReverseOptions",
82
82
  "slug": "reverseoptions",
83
83
  "docs": "",
84
84
  "tags": [],
@@ -129,8 +129,8 @@
129
129
  ]
130
130
  },
131
131
  {
132
- "name": "Adress",
133
- "slug": "adress",
132
+ "name": "Address",
133
+ "slug": "address",
134
134
  "docs": "",
135
135
  "tags": [],
136
136
  "methods": [],
@@ -1,4 +1,4 @@
1
- export interface Adress {
1
+ export interface Address {
2
2
  latitude: number;
3
3
  longitude: number;
4
4
  countryCode: string;
@@ -34,7 +34,7 @@ export interface ForwardOptions {
34
34
  */
35
35
  apiKey?: string;
36
36
  }
37
- export interface reverseOptions {
37
+ export interface ReverseOptions {
38
38
  /**
39
39
  * latitude is a number representing the latitude of the location.
40
40
  */
@@ -65,21 +65,21 @@ export interface NativeGeocoderPlugin {
65
65
  * Convert latitude and longitude to an address
66
66
  *
67
67
  * @param id The bundle id to delete (note, this is the bundle id, NOT the version name)
68
- * @returns {Promise<{addresses: Adress[]}>} an Promise with the list of addresses according to maxResults
68
+ * @returns {Promise<{addresses: Address[]}>} an Promise with the list of addresses according to maxResults
69
69
  * @throws An error if the something went wrong
70
70
  * @since 0.0.1
71
71
  */
72
- reverseGeocode(options: reverseOptions): Promise<{
73
- addresses: Adress[];
72
+ reverseGeocode(options: ReverseOptions): Promise<{
73
+ addresses: Address[];
74
74
  }>;
75
75
  /**
76
76
  * Convert an address to latitude and longitude
77
77
  *
78
- * @returns {Promise<{addresses: Adress[]}>} an Promise with the list of addresses according to maxResults
78
+ * @returns {Promise<{addresses: Address[]}>} an Promise with the list of addresses according to maxResults
79
79
  * @throws An error if the something went wrong
80
80
  * @since 0.0.1
81
81
  */
82
82
  forwardGeocode(options: ForwardOptions): Promise<{
83
- addresses: Adress[];
83
+ addresses: Address[];
84
84
  }>;
85
85
  }
@@ -1 +1 @@
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"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface Address {\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: Address[]}>} 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: Address[] }>;\n /**\n * Convert an address to latitude and longitude\n *\n * @returns {Promise<{addresses: Address[]}>} 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: Address[] }>;\n}\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { WebPlugin } from "@capacitor/core";
2
- import type { NativeGeocoderPlugin, reverseOptions, ForwardOptions, Adress } from "./definitions";
2
+ import type { NativeGeocoderPlugin, ReverseOptions, ForwardOptions, Address } from "./definitions";
3
3
  export declare class NativeGeocoderWeb extends WebPlugin implements NativeGeocoderPlugin {
4
- reverseGeocode(options: reverseOptions): Promise<{
5
- addresses: Adress[];
4
+ reverseGeocode(options: ReverseOptions): Promise<{
5
+ addresses: Address[];
6
6
  }>;
7
7
  forwardGeocode(options: ForwardOptions): Promise<{
8
- addresses: Adress[];
8
+ addresses: Address[];
9
9
  }>;
10
10
  }
package/dist/esm/web.js CHANGED
@@ -18,8 +18,8 @@ export class NativeGeocoderWeb extends WebPlugin {
18
18
  return {
19
19
  addresses: data.results
20
20
  .map((result) => {
21
- // transform the response in Adress[]
22
- // use the restul from google geocoder and transform it in Adress
21
+ // transform the response in Address[]
22
+ // use the result from google geocoder and transform it in Address
23
23
  return {
24
24
  latitude: result.geometry.location.lat,
25
25
  longitude: result.geometry.location.lng,
@@ -56,8 +56,8 @@ export class NativeGeocoderWeb extends WebPlugin {
56
56
  return {
57
57
  addresses: data.results
58
58
  .map((result) => {
59
- // transform the response in Adress[]
60
- // use the restul from google geocoder and transform it in Adress
59
+ // transform the response in Address[]
60
+ // use the result from google geocoder and transform it in Address
61
61
  return {
62
62
  latitude: result.geometry.location.lat,
63
63
  longitude: result.geometry.location.lng,
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AA2C5C,MAAM,MAAM,GAAG,CACb,kBAAsC,EACtC,IAAY,EACM,EAAE;IACpB,OAAO,CACL,kBAAkB,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CA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QACJ,CAAC,CAAC,CAAC;IACP,CAAC;CACF","sourcesContent":["import { WebPlugin } from \"@capacitor/core\";\n\nimport type {\n NativeGeocoderPlugin,\n reverseOptions,\n ForwardOptions,\n Adress,\n} 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 = (\n address_components: AddressComponent[],\n type: string\n): 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\n extends WebPlugin\n implements NativeGeocoderPlugin\n{\n async reverseGeocode(\n options: reverseOptions\n ): 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(\n `https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(\n params\n ).toString()}`\n )\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\")\n .short_name,\n countryName: findAC(result.address_components, \"country\")\n .long_name,\n postalCode: findAC(result.address_components, \"postal_code\")\n .long_name,\n administrativeArea: findAC(\n result.address_components,\n \"administrative_area_level_1\"\n ).long_name,\n subAdministrativeArea: findAC(\n result.address_components,\n \"administrative_area_level_2\"\n ).long_name,\n locality: findAC(result.address_components, \"locality\")\n .long_name,\n subLocality: findAC(result.address_components, \"sublocality\")\n .long_name,\n thoroughfare: findAC(result.address_components, \"route\")\n .long_name,\n subThoroughfare: findAC(\n result.address_components,\n \"street_number\"\n ).long_name,\n areasOfInterest: [],\n };\n })\n .slice(0, options.maxResults || 1),\n };\n });\n }\n async forwardGeocode(\n options: ForwardOptions\n ): 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(\n `https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(\n params\n ).toString()}`\n )\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\")\n .short_name,\n countryName: findAC(result.address_components, \"country\")\n .long_name,\n postalCode: findAC(result.address_components, \"postal_code\")\n .long_name,\n administrativeArea: findAC(\n result.address_components,\n \"administrative_area_level_1\"\n ).long_name,\n subAdministrativeArea: findAC(\n result.address_components,\n \"administrative_area_level_2\"\n ).long_name,\n locality: findAC(result.address_components, \"locality\")\n .long_name,\n subLocality: findAC(result.address_components, \"sublocality\")\n .long_name,\n thoroughfare: findAC(result.address_components, \"route\")\n .long_name,\n subThoroughfare: findAC(\n result.address_components,\n \"street_number\"\n ).long_name,\n areasOfInterest: [],\n };\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;AA2C5C,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CAAC,SAAS;wBACX,eAAe,EAAE,EAAE;qBACpB,CAAC;gBACJ,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 {\n NativeGeocoderPlugin,\n ReverseOptions,\n ForwardOptions,\n Address,\n} 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 = (\n address_components: AddressComponent[],\n type: string\n): 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\n extends WebPlugin\n implements NativeGeocoderPlugin\n{\n async reverseGeocode(\n options: ReverseOptions\n ): Promise<{ addresses: Address[] }> {\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(\n `https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(\n params\n ).toString()}`\n )\n .then((response) => response.json())\n .then((data: GeocoderPayload): { addresses: Address[] } => {\n return {\n addresses: data.results\n .map((result: GeocoderResult): Address => {\n // transform the response in Address[]\n // use the result from google geocoder and transform it in Address\n\n return {\n latitude: result.geometry.location.lat,\n longitude: result.geometry.location.lng,\n countryCode: findAC(result.address_components, \"country\")\n .short_name,\n countryName: findAC(result.address_components, \"country\")\n .long_name,\n postalCode: findAC(result.address_components, \"postal_code\")\n .long_name,\n administrativeArea: findAC(\n result.address_components,\n \"administrative_area_level_1\"\n ).long_name,\n subAdministrativeArea: findAC(\n result.address_components,\n \"administrative_area_level_2\"\n ).long_name,\n locality: findAC(result.address_components, \"locality\")\n .long_name,\n subLocality: findAC(result.address_components, \"sublocality\")\n .long_name,\n thoroughfare: findAC(result.address_components, \"route\")\n .long_name,\n subThoroughfare: findAC(\n result.address_components,\n \"street_number\"\n ).long_name,\n areasOfInterest: [],\n };\n })\n .slice(0, options.maxResults || 1),\n };\n });\n }\n async forwardGeocode(\n options: ForwardOptions\n ): Promise<{ addresses: Address[] }> {\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(\n `https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(\n params\n ).toString()}`\n )\n .then((response) => response.json())\n .then((data: GeocoderPayload): { addresses: Address[] } => {\n return {\n addresses: data.results\n .map((result: GeocoderResult): Address => {\n // transform the response in Address[]\n // use the result from google geocoder and transform it in Address\n return {\n latitude: result.geometry.location.lat,\n longitude: result.geometry.location.lng,\n countryCode: findAC(result.address_components, \"country\")\n .short_name,\n countryName: findAC(result.address_components, \"country\")\n .long_name,\n postalCode: findAC(result.address_components, \"postal_code\")\n .long_name,\n administrativeArea: findAC(\n result.address_components,\n \"administrative_area_level_1\"\n ).long_name,\n subAdministrativeArea: findAC(\n result.address_components,\n \"administrative_area_level_2\"\n ).long_name,\n locality: findAC(result.address_components, \"locality\")\n .long_name,\n subLocality: findAC(result.address_components, \"sublocality\")\n .long_name,\n thoroughfare: findAC(result.address_components, \"route\")\n .long_name,\n subThoroughfare: findAC(\n result.address_components,\n \"street_number\"\n ).long_name,\n areasOfInterest: [],\n };\n })\n .slice(0, options.maxResults || 1),\n };\n });\n }\n}\n"]}
@@ -25,8 +25,8 @@ class NativeGeocoderWeb extends core.WebPlugin {
25
25
  return {
26
26
  addresses: data.results
27
27
  .map((result) => {
28
- // transform the response in Adress[]
29
- // use the restul from google geocoder and transform it in Adress
28
+ // transform the response in Address[]
29
+ // use the result from google geocoder and transform it in Address
30
30
  return {
31
31
  latitude: result.geometry.location.lat,
32
32
  longitude: result.geometry.location.lng,
@@ -63,8 +63,8 @@ class NativeGeocoderWeb extends core.WebPlugin {
63
63
  return {
64
64
  addresses: data.results
65
65
  .map((result) => {
66
- // transform the response in Adress[]
67
- // use the restul from google geocoder and transform it in Adress
66
+ // transform the response in Address[]
67
+ // use the result from google geocoder and transform it in Address
68
68
  return {
69
69
  latitude: result.geometry.location.lat,
70
70
  longitude: result.geometry.location.lng,
@@ -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)) || {\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\")\n .short_name,\n countryName: findAC(result.address_components, \"country\")\n .long_name,\n postalCode: findAC(result.address_components, \"postal_code\")\n .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\")\n .long_name,\n subLocality: findAC(result.address_components, \"sublocality\")\n .long_name,\n thoroughfare: findAC(result.address_components, \"route\")\n .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\")\n .short_name,\n countryName: findAC(result.address_components, \"country\")\n .long_name,\n postalCode: findAC(result.address_components, \"postal_code\")\n .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\")\n .long_name,\n subLocality: findAC(result.address_components, \"sublocality\")\n .long_name,\n thoroughfare: findAC(result.address_components, \"route\")\n .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,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CAAC,MAAM,CAAC,kBAAkB,EAAE,SAAS,CAAC;AACjF,6BAA6B,SAAS;AACtC,wBAAwB,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,aAAa,CAAC;AACpF,6BAA6B,SAAS;AACtC,wBAAwB,kBAAkB,EAAE,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;AAC/E,6BAA6B,SAAS;AACtC,wBAAwB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,aAAa,CAAC;AACrF,6BAA6B,SAAS;AACtC,wBAAwB,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC;AAChF,6BAA6B,SAAS;AACtC,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;;;;;;;;;"}
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 Address[]\n // use the result from google geocoder and transform it in Address\n return {\n latitude: result.geometry.location.lat,\n longitude: result.geometry.location.lng,\n countryCode: findAC(result.address_components, \"country\")\n .short_name,\n countryName: findAC(result.address_components, \"country\")\n .long_name,\n postalCode: findAC(result.address_components, \"postal_code\")\n .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\")\n .long_name,\n subLocality: findAC(result.address_components, \"sublocality\")\n .long_name,\n thoroughfare: findAC(result.address_components, \"route\")\n .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 Address[]\n // use the result from google geocoder and transform it in Address\n return {\n latitude: result.geometry.location.lat,\n longitude: result.geometry.location.lng,\n countryCode: findAC(result.address_components, \"country\")\n .short_name,\n countryName: findAC(result.address_components, \"country\")\n .long_name,\n postalCode: findAC(result.address_components, \"postal_code\")\n .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\")\n .long_name,\n subLocality: findAC(result.address_components, \"sublocality\")\n .long_name,\n thoroughfare: findAC(result.address_components, \"route\")\n .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,iBAAiB,EAAE,CAAC;AACrE,CAAC;;ACFD,MAAM,MAAM,GAAG,CAAC,kBAAkB,EAAE,IAAI,KAAK;AAC7C,IAAI,QAAQ,kBAAkB,CAAC,IAAI,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI;AACtF,QAAQ,SAAS,EAAE,EAAE;AACrB,QAAQ,UAAU,EAAE,EAAE;AACtB,QAAQ,KAAK,EAAE,EAAE;AACjB,KAAK,EAAE;AACP,CAAC,CAAC;AACK,MAAM,iBAAiB,SAASC,cAAS,CAAC;AACjD,IAAI,MAAM,cAAc,CAAC,OAAO,EAAE;AAClC,QAAQ,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;AAC7B,YAAY,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;AAC1D,SAAS;AACT,QAAQ,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,QAAQ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tB,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
@@ -24,8 +24,8 @@ var capacitorNativeGeocoder = (function (exports, core) {
24
24
  return {
25
25
  addresses: data.results
26
26
  .map((result) => {
27
- // transform the response in Adress[]
28
- // use the restul from google geocoder and transform it in Adress
27
+ // transform the response in Address[]
28
+ // use the result from google geocoder and transform it in Address
29
29
  return {
30
30
  latitude: result.geometry.location.lat,
31
31
  longitude: result.geometry.location.lng,
@@ -62,8 +62,8 @@ var capacitorNativeGeocoder = (function (exports, core) {
62
62
  return {
63
63
  addresses: data.results
64
64
  .map((result) => {
65
- // transform the response in Adress[]
66
- // use the restul from google geocoder and transform it in Adress
65
+ // transform the response in Address[]
66
+ // use the result from google geocoder and transform it in Address
67
67
  return {
68
68
  latitude: result.geometry.location.lat,
69
69
  longitude: result.geometry.location.lng,
@@ -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)) || {\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\")\n .short_name,\n countryName: findAC(result.address_components, \"country\")\n .long_name,\n postalCode: findAC(result.address_components, \"postal_code\")\n .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\")\n .long_name,\n subLocality: findAC(result.address_components, \"sublocality\")\n .long_name,\n thoroughfare: findAC(result.address_components, \"route\")\n .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\")\n .short_name,\n countryName: findAC(result.address_components, \"country\")\n .long_name,\n postalCode: findAC(result.address_components, \"postal_code\")\n .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\")\n .long_name,\n subLocality: findAC(result.address_components, \"sublocality\")\n .long_name,\n thoroughfare: findAC(result.address_components, \"route\")\n .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,kBAAkB,CAAC,IAAI,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI;IACtF,QAAQ,SAAS,EAAE,EAAE;IACrB,QAAQ,UAAU,EAAE,EAAE;IACtB,QAAQ,KAAK,EAAE,EAAE;IACjB,KAAK,EAAE;IACP,CAAC,CAAC;IACK,MAAM,iBAAiB,SAASC,cAAS,CAAC;IACjD,IAAI,MAAM,cAAc,CAAC,OAAO,EAAE;IAClC,QAAQ,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;IAC7B,YAAY,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAC1D,SAAS;IACT,QAAQ,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,aAAa,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC,CAAC;IACpO,QAAQ,OAAO,KAAK,CAAC,CAAC,kDAAkD,EAAE,IAAI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QAAQ,CAAC,QAAQ,CAAC,GAAG;IAC/D,wBAAwB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,SAAS,CAAC;IACjF,6BAA6B,UAAU;IACvC,wBAAwB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,SAAS,CAAC;IACjF,6BAA6B,SAAS;IACtC,wBAAwB,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,aAAa,CAAC;IACpF,6BAA6B,SAAS;IACtC,wBAAwB,kBAAkB,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,6BAA6B,CAAC,CAAC,SAAS;IACtH,wBAAwB,qBAAqB,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,6BAA6B,CAAC,CAAC,SAAS;IACzH,wBAAwB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,UAAU,CAAC;IAC/E,6BAA6B,SAAS;IACtC,wBAAwB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,aAAa,CAAC;IACrF,6BAA6B,SAAS;IACtC,wBAAwB,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC;IAChF,6BAA6B,SAAS;IACtC,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;;;;;;;;;;;;;;;"}
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 Address[]\n // use the result from google geocoder and transform it in Address\n return {\n latitude: result.geometry.location.lat,\n longitude: result.geometry.location.lng,\n countryCode: findAC(result.address_components, \"country\")\n .short_name,\n countryName: findAC(result.address_components, \"country\")\n .long_name,\n postalCode: findAC(result.address_components, \"postal_code\")\n .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\")\n .long_name,\n subLocality: findAC(result.address_components, \"sublocality\")\n .long_name,\n thoroughfare: findAC(result.address_components, \"route\")\n .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 Address[]\n // use the result from google geocoder and transform it in Address\n return {\n latitude: result.geometry.location.lat,\n longitude: result.geometry.location.lng,\n countryCode: findAC(result.address_components, \"country\")\n .short_name,\n countryName: findAC(result.address_components, \"country\")\n .long_name,\n postalCode: findAC(result.address_components, \"postal_code\")\n .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\")\n .long_name,\n subLocality: findAC(result.address_components, \"sublocality\")\n .long_name,\n thoroughfare: findAC(result.address_components, \"route\")\n .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,kBAAkB,CAAC,IAAI,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI;IACtF,QAAQ,SAAS,EAAE,EAAE;IACrB,QAAQ,UAAU,EAAE,EAAE;IACtB,QAAQ,KAAK,EAAE,EAAE;IACjB,KAAK,EAAE;IACP,CAAC,CAAC;IACK,MAAM,iBAAiB,SAASC,cAAS,CAAC;IACjD,IAAI,MAAM,cAAc,CAAC,OAAO,EAAE;IAClC,QAAQ,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;IAC7B,YAAY,MAAM,IAAI,KAAK,C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AChF,6BAA6B,SAAS;IACtC,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;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/nativegeocoder",
3
- "version": "1.0.9",
3
+ "version": "1.0.12",
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",