@capgo/nativegeocoder 0.1.20 → 0.1.23
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/dist/esm/web.js +4 -4
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +4 -4
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +4 -4
- package/dist/plugin.js.map +1 -1
- package/package.json +2 -2
package/dist/esm/web.js
CHANGED
|
@@ -8,11 +8,11 @@ export class NativeGeocoderWeb extends WebPlugin {
|
|
|
8
8
|
throw new Error('apiKey is required for web');
|
|
9
9
|
}
|
|
10
10
|
const params = Object.assign(Object.assign({ latlng: `${options.latitude},${options.longitude}`, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });
|
|
11
|
-
return fetch(`https://maps.googleapis.com/maps/api/geocode/json
|
|
11
|
+
return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)
|
|
12
12
|
.then(response => response.json())
|
|
13
13
|
.then((data) => {
|
|
14
14
|
return {
|
|
15
|
-
addresses: data.results.
|
|
15
|
+
addresses: data.results.map((result) => {
|
|
16
16
|
// transform the response in Adress[]
|
|
17
17
|
// use the restul from google geocoder and transform it in Adress
|
|
18
18
|
return {
|
|
@@ -39,11 +39,11 @@ export class NativeGeocoderWeb extends WebPlugin {
|
|
|
39
39
|
throw new Error('apiKey is required for web');
|
|
40
40
|
}
|
|
41
41
|
const params = Object.assign(Object.assign({ address: options.addressString, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });
|
|
42
|
-
return fetch(`https://maps.googleapis.com/maps/api/geocode/json
|
|
42
|
+
return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)
|
|
43
43
|
.then(response => response.json())
|
|
44
44
|
.then((data) => {
|
|
45
45
|
return {
|
|
46
|
-
addresses: data.results.
|
|
46
|
+
addresses: data.results.map((result) => {
|
|
47
47
|
// transform the response in Adress[]
|
|
48
48
|
// use the restul from google geocoder and transform it in Adress
|
|
49
49
|
return {
|
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;
|
|
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;IACxF,OAAO,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AAC9H,CAAC,CAAA;AACD,MAAM,OAAO,iBACX,SAAQ,SAAS;IAEf,KAAK,CAAC,cAAc,CAAC,OAAuB;QAC1C,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;SAC/C;QACD,MAAM,MAAM,iCACV,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,SAAS,EAAE,EAClD,GAAG,EAAE,OAAO,CAAC,MAAM,IAChB,CAAC,OAAO,CAAC,aAAa,IAAI,EAAC,QAAQ,EAAE,OAAO,CAAC,aAAa,EAAC,CAAC,KAC/D,WAAW,EAAE,gBAAgB,GAC9B,CAAA;QACD,OAAO,KAAK,CAAC,qDAAqD,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC;aACxG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QA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AC,MAAM,CAAC,kBAAkB,EAAE,6BAA6B,CAAC,CAAC,SAAS;wBACjG,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC,SAAS;wBACjE,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC,SAAS;wBACvE,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC,SAAS;wBAClE,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,eAAe,CAAC,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"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -17,11 +17,11 @@ class NativeGeocoderWeb extends core.WebPlugin {
|
|
|
17
17
|
throw new Error('apiKey is required for web');
|
|
18
18
|
}
|
|
19
19
|
const params = Object.assign(Object.assign({ latlng: `${options.latitude},${options.longitude}`, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });
|
|
20
|
-
return fetch(`https://maps.googleapis.com/maps/api/geocode/json
|
|
20
|
+
return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)
|
|
21
21
|
.then(response => response.json())
|
|
22
22
|
.then((data) => {
|
|
23
23
|
return {
|
|
24
|
-
addresses: data.results.
|
|
24
|
+
addresses: data.results.map((result) => {
|
|
25
25
|
// transform the response in Adress[]
|
|
26
26
|
// use the restul from google geocoder and transform it in Adress
|
|
27
27
|
return {
|
|
@@ -48,11 +48,11 @@ class NativeGeocoderWeb extends core.WebPlugin {
|
|
|
48
48
|
throw new Error('apiKey is required for web');
|
|
49
49
|
}
|
|
50
50
|
const params = Object.assign(Object.assign({ address: options.addressString, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });
|
|
51
|
-
return fetch(`https://maps.googleapis.com/maps/api/geocode/json
|
|
51
|
+
return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)
|
|
52
52
|
.then(response => response.json())
|
|
53
53
|
.then((data) => {
|
|
54
54
|
return {
|
|
55
|
-
addresses: data.results.
|
|
55
|
+
addresses: data.results.map((result) => {
|
|
56
56
|
// transform the response in Adress[]
|
|
57
57
|
// use the restul from google geocoder and transform it in Adress
|
|
58
58
|
return {
|
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)) || { 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
|
|
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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,aAAa,CAAC,CAAC,SAAS;AAC9F,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,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,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC;AACpD,aAAa,CAAC;AACd,SAAS,CAAC,CAAC;AACX,KAAK;AACL;AACA;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -14,11 +14,11 @@ var capacitorNativeGeocoder = (function (exports, core) {
|
|
|
14
14
|
throw new Error('apiKey is required for web');
|
|
15
15
|
}
|
|
16
16
|
const params = Object.assign(Object.assign({ latlng: `${options.latitude},${options.longitude}`, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });
|
|
17
|
-
return fetch(`https://maps.googleapis.com/maps/api/geocode/json
|
|
17
|
+
return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)
|
|
18
18
|
.then(response => response.json())
|
|
19
19
|
.then((data) => {
|
|
20
20
|
return {
|
|
21
|
-
addresses: data.results.
|
|
21
|
+
addresses: data.results.map((result) => {
|
|
22
22
|
// transform the response in Adress[]
|
|
23
23
|
// use the restul from google geocoder and transform it in Adress
|
|
24
24
|
return {
|
|
@@ -45,11 +45,11 @@ var capacitorNativeGeocoder = (function (exports, core) {
|
|
|
45
45
|
throw new Error('apiKey is required for web');
|
|
46
46
|
}
|
|
47
47
|
const params = Object.assign(Object.assign({ address: options.addressString, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });
|
|
48
|
-
return fetch(`https://maps.googleapis.com/maps/api/geocode/json
|
|
48
|
+
return fetch(`https://maps.googleapis.com/maps/api/geocode/json?${new URLSearchParams(params).toString()}`)
|
|
49
49
|
.then(response => response.json())
|
|
50
50
|
.then((data) => {
|
|
51
51
|
return {
|
|
52
|
-
addresses: data.results.
|
|
52
|
+
addresses: data.results.map((result) => {
|
|
53
53
|
// transform the response in Adress[]
|
|
54
54
|
// use the restul from google geocoder and transform it in Adress
|
|
55
55
|
return {
|
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)) || { 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
|
|
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;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,MA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K,CAAC,CAAC,EAAE,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC;IACpD,aAAa,CAAC;IACd,SAAS,CAAC,CAAC;IACX,KAAK;IACL;IACA;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/nativegeocoder",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.23",
|
|
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",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"typescript": "~4.0.3"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"@capacitor/core": "^3.0.0"
|
|
65
|
+
"@capacitor/core": "^3.0.0 || ^4.0.0"
|
|
66
66
|
},
|
|
67
67
|
"prettier": "@ionic/prettier-config",
|
|
68
68
|
"swiftlint": "@ionic/swiftlint-config",
|