@capgo/nativegeocoder 6.0.57 → 6.1.0
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 +9 -0
- package/dist/docs.json +7 -0
- package/dist/esm/definitions.d.ts +4 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.js +1 -1
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +1 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,6 +42,14 @@ This API requires the following permissions be added to your `AndroidManifest.xm
|
|
|
42
42
|
<uses-feature android:name="android.hardware.location.gps" />
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
+
## Web
|
|
46
|
+
|
|
47
|
+
This API requires a Google API key to be set in the `apiKey` field of the `ForwardOptions` or `ReverseOptions` interfaces.
|
|
48
|
+
|
|
49
|
+
There is no way to use this plugin on the web without a Google API key.
|
|
50
|
+
|
|
51
|
+
The return data is limited to the data available from the native API on the device, as exemple `formatted_address` is not available in web implementation, as it's not available in the native API.
|
|
52
|
+
|
|
45
53
|
## API
|
|
46
54
|
|
|
47
55
|
<docgen-index>
|
|
@@ -106,6 +114,7 @@ Convert an address to latitude and longitude
|
|
|
106
114
|
| **`defaultLocale`** | <code>string</code> | locale is a string in the format of language_country, for example en_US. |
|
|
107
115
|
| **`maxResults`** | <code>number</code> | Max number of results to return. |
|
|
108
116
|
| **`apiKey`** | <code>string</code> | Only used for web platform to use google api |
|
|
117
|
+
| **`resultType`** | <code>string</code> | Only used for web platform to use google api |
|
|
109
118
|
|
|
110
119
|
|
|
111
120
|
#### Address
|
package/dist/docs.json
CHANGED
|
@@ -125,6 +125,13 @@
|
|
|
125
125
|
"docs": "Only used for web platform to use google api",
|
|
126
126
|
"complexTypes": [],
|
|
127
127
|
"type": "string | undefined"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"name": "resultType",
|
|
131
|
+
"tags": [],
|
|
132
|
+
"docs": "Only used for web platform to use google api",
|
|
133
|
+
"complexTypes": [],
|
|
134
|
+
"type": "string | undefined"
|
|
128
135
|
}
|
|
129
136
|
]
|
|
130
137
|
},
|
|
@@ -1 +1 @@
|
|
|
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"]}
|
|
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 /**\n * Only used for web platform to use google api\n */\n resultType?: 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.js
CHANGED
|
@@ -11,7 +11,7 @@ export class NativeGeocoderWeb extends WebPlugin {
|
|
|
11
11
|
if (!options.apiKey) {
|
|
12
12
|
throw new Error("apiKey is required for web");
|
|
13
13
|
}
|
|
14
|
-
const params = Object.assign(Object.assign({ latlng: `${options.latitude},${options.longitude}`, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: "street_address" });
|
|
14
|
+
const params = Object.assign(Object.assign({ latlng: `${options.latitude},${options.longitude}`, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: options.resultType || "street_address" });
|
|
15
15
|
return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)
|
|
16
16
|
.then((response) => response.json())
|
|
17
17
|
.then((data) => {
|
package/dist/esm/web.js.map
CHANGED
|
@@ -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,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI;QACxE,SAAS,EAAE,EAAE;QACb,UAAU,EAAE,EAAE;QACd,KAAK,EAAE,EAAE;KACV,CACF,CAAC;AACJ,CAAC,CAAC;AACF,MAAM,OAAO,iBACX,SAAQ,SAAS;IAGjB,KAAK,CAAC,cAAc,CAClB,OAAuB;QAEvB,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;QACD,MAAM,MAAM,iCACV,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,SAAS,EAAE,EAClD,GAAG,EAAE,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AE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,UAAU,CAAC;6BACpD,SAAS;wBACZ,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,aAAa,CAAC;6BAC1D,SAAS;wBACZ,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC;6BACrD,SAAS;wBACZ,eAAe,EAAE,MAAM,CACrB,MAAM,CAAC,kBAAkB,EACzB,eAAe,CAChB,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: options.resultType || \"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"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -18,7 +18,7 @@ class NativeGeocoderWeb extends core.WebPlugin {
|
|
|
18
18
|
if (!options.apiKey) {
|
|
19
19
|
throw new Error("apiKey is required for web");
|
|
20
20
|
}
|
|
21
|
-
const params = Object.assign(Object.assign({ latlng: `${options.latitude},${options.longitude}`, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: "street_address" });
|
|
21
|
+
const params = Object.assign(Object.assign({ latlng: `${options.latitude},${options.longitude}`, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: options.resultType || "street_address" });
|
|
22
22
|
return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)
|
|
23
23
|
.then((response) => response.json())
|
|
24
24
|
.then((data) => {
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -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 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,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;
|
|
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: options.resultType || \"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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B,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;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -17,7 +17,7 @@ var capacitorNativeGeocoder = (function (exports, core) {
|
|
|
17
17
|
if (!options.apiKey) {
|
|
18
18
|
throw new Error("apiKey is required for web");
|
|
19
19
|
}
|
|
20
|
-
const params = Object.assign(Object.assign({ latlng: `${options.latitude},${options.longitude}`, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: "street_address" });
|
|
20
|
+
const params = Object.assign(Object.assign({ latlng: `${options.latitude},${options.longitude}`, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: options.resultType || "street_address" });
|
|
21
21
|
return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)
|
|
22
22
|
.then((response) => response.json())
|
|
23
23
|
.then((data) => {
|
package/dist/plugin.js.map
CHANGED
|
@@ -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 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,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;
|
|
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: options.resultType || \"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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