@capgo/nativegeocoder 0.0.1
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/CapgoNativegeocoder.podspec +17 -0
- package/README.md +98 -0
- package/android/build.gradle +58 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/ee/forgr/plugin/nativegeocoder/NativeGeocoder.java +239 -0
- package/android/src/main/java/ee/forgr/plugin/nativegeocoder/NativeGeocoderPlugin.java +39 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +242 -0
- package/dist/esm/definitions.d.ts +37 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +10 -0
- package/dist/esm/web.js +62 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +78 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +81 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/NativeGeocoder.swift +242 -0
- package/ios/Plugin/NativeGeocoderPlugin.h +10 -0
- package/ios/Plugin/NativeGeocoderPlugin.m +9 -0
- package/ios/Plugin/NativeGeocoderPlugin.swift +31 -0
- package/package.json +79 -0
package/dist/docs.json
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "NativeGeocoderPlugin",
|
|
4
|
+
"slug": "nativegeocoderplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "reverseGeocode",
|
|
10
|
+
"signature": "(options: reverseOptions) => Promise<{ addresses: Adress[]; }>",
|
|
11
|
+
"parameters": [
|
|
12
|
+
{
|
|
13
|
+
"name": "options",
|
|
14
|
+
"docs": "",
|
|
15
|
+
"type": "reverseOptions"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"returns": "Promise<{ addresses: Adress[]; }>",
|
|
19
|
+
"tags": [],
|
|
20
|
+
"docs": "",
|
|
21
|
+
"complexTypes": [
|
|
22
|
+
"Adress",
|
|
23
|
+
"reverseOptions"
|
|
24
|
+
],
|
|
25
|
+
"slug": "reversegeocode"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "forwardGeocode",
|
|
29
|
+
"signature": "(options: ForwardOptions) => Promise<{ addresses: Adress[]; }>",
|
|
30
|
+
"parameters": [
|
|
31
|
+
{
|
|
32
|
+
"name": "options",
|
|
33
|
+
"docs": "",
|
|
34
|
+
"type": "ForwardOptions"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"returns": "Promise<{ addresses: Adress[]; }>",
|
|
38
|
+
"tags": [],
|
|
39
|
+
"docs": "",
|
|
40
|
+
"complexTypes": [
|
|
41
|
+
"Adress",
|
|
42
|
+
"ForwardOptions"
|
|
43
|
+
],
|
|
44
|
+
"slug": "forwardgeocode"
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"properties": []
|
|
48
|
+
},
|
|
49
|
+
"interfaces": [
|
|
50
|
+
{
|
|
51
|
+
"name": "Adress",
|
|
52
|
+
"slug": "adress",
|
|
53
|
+
"docs": "",
|
|
54
|
+
"tags": [],
|
|
55
|
+
"methods": [],
|
|
56
|
+
"properties": [
|
|
57
|
+
{
|
|
58
|
+
"name": "latitude",
|
|
59
|
+
"tags": [],
|
|
60
|
+
"docs": "",
|
|
61
|
+
"complexTypes": [],
|
|
62
|
+
"type": "string"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "longitude",
|
|
66
|
+
"tags": [],
|
|
67
|
+
"docs": "",
|
|
68
|
+
"complexTypes": [],
|
|
69
|
+
"type": "string"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"name": "countryCode",
|
|
73
|
+
"tags": [],
|
|
74
|
+
"docs": "",
|
|
75
|
+
"complexTypes": [],
|
|
76
|
+
"type": "string"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"name": "postalCode",
|
|
80
|
+
"tags": [],
|
|
81
|
+
"docs": "",
|
|
82
|
+
"complexTypes": [],
|
|
83
|
+
"type": "string"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"name": "administrativeArea",
|
|
87
|
+
"tags": [],
|
|
88
|
+
"docs": "",
|
|
89
|
+
"complexTypes": [],
|
|
90
|
+
"type": "string"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"name": "subAdministrativeArea",
|
|
94
|
+
"tags": [],
|
|
95
|
+
"docs": "",
|
|
96
|
+
"complexTypes": [],
|
|
97
|
+
"type": "string"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"name": "locality",
|
|
101
|
+
"tags": [],
|
|
102
|
+
"docs": "",
|
|
103
|
+
"complexTypes": [],
|
|
104
|
+
"type": "string"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"name": "subLocality",
|
|
108
|
+
"tags": [],
|
|
109
|
+
"docs": "",
|
|
110
|
+
"complexTypes": [],
|
|
111
|
+
"type": "string"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"name": "thoroughfare",
|
|
115
|
+
"tags": [],
|
|
116
|
+
"docs": "",
|
|
117
|
+
"complexTypes": [],
|
|
118
|
+
"type": "string"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"name": "subThoroughfare",
|
|
122
|
+
"tags": [],
|
|
123
|
+
"docs": "",
|
|
124
|
+
"complexTypes": [],
|
|
125
|
+
"type": "string"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"name": "areasOfInterest",
|
|
129
|
+
"tags": [],
|
|
130
|
+
"docs": "",
|
|
131
|
+
"complexTypes": [],
|
|
132
|
+
"type": "string[]"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"name": "formatted_address",
|
|
136
|
+
"tags": [],
|
|
137
|
+
"docs": "",
|
|
138
|
+
"complexTypes": [],
|
|
139
|
+
"type": "string"
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"name": "reverseOptions",
|
|
145
|
+
"slug": "reverseoptions",
|
|
146
|
+
"docs": "",
|
|
147
|
+
"tags": [],
|
|
148
|
+
"methods": [],
|
|
149
|
+
"properties": [
|
|
150
|
+
{
|
|
151
|
+
"name": "latitude",
|
|
152
|
+
"tags": [],
|
|
153
|
+
"docs": "",
|
|
154
|
+
"complexTypes": [],
|
|
155
|
+
"type": "number"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"name": "longitude",
|
|
159
|
+
"tags": [],
|
|
160
|
+
"docs": "",
|
|
161
|
+
"complexTypes": [],
|
|
162
|
+
"type": "number"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"name": "useLocale",
|
|
166
|
+
"tags": [],
|
|
167
|
+
"docs": "",
|
|
168
|
+
"complexTypes": [],
|
|
169
|
+
"type": "boolean | undefined"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"name": "defaultLocale",
|
|
173
|
+
"tags": [],
|
|
174
|
+
"docs": "",
|
|
175
|
+
"complexTypes": [],
|
|
176
|
+
"type": "string | undefined"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"name": "maxResults",
|
|
180
|
+
"tags": [],
|
|
181
|
+
"docs": "",
|
|
182
|
+
"complexTypes": [],
|
|
183
|
+
"type": "number | undefined"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"name": "apiKey",
|
|
187
|
+
"tags": [],
|
|
188
|
+
"docs": "",
|
|
189
|
+
"complexTypes": [],
|
|
190
|
+
"type": "string | undefined"
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"name": "ForwardOptions",
|
|
196
|
+
"slug": "forwardoptions",
|
|
197
|
+
"docs": "",
|
|
198
|
+
"tags": [],
|
|
199
|
+
"methods": [],
|
|
200
|
+
"properties": [
|
|
201
|
+
{
|
|
202
|
+
"name": "addressString",
|
|
203
|
+
"tags": [],
|
|
204
|
+
"docs": "",
|
|
205
|
+
"complexTypes": [],
|
|
206
|
+
"type": "string"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"name": "useLocale",
|
|
210
|
+
"tags": [],
|
|
211
|
+
"docs": "",
|
|
212
|
+
"complexTypes": [],
|
|
213
|
+
"type": "boolean | undefined"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"name": "defaultLocale",
|
|
217
|
+
"tags": [],
|
|
218
|
+
"docs": "",
|
|
219
|
+
"complexTypes": [],
|
|
220
|
+
"type": "string | undefined"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"name": "maxResults",
|
|
224
|
+
"tags": [],
|
|
225
|
+
"docs": "",
|
|
226
|
+
"complexTypes": [],
|
|
227
|
+
"type": "number | undefined"
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"name": "apiKey",
|
|
231
|
+
"tags": [],
|
|
232
|
+
"docs": "",
|
|
233
|
+
"complexTypes": [],
|
|
234
|
+
"type": "string | undefined"
|
|
235
|
+
}
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
],
|
|
239
|
+
"enums": [],
|
|
240
|
+
"typeAliases": [],
|
|
241
|
+
"pluginConfigs": []
|
|
242
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface Adress {
|
|
2
|
+
latitude: string;
|
|
3
|
+
longitude: string;
|
|
4
|
+
countryCode: string;
|
|
5
|
+
postalCode: string;
|
|
6
|
+
administrativeArea: string;
|
|
7
|
+
subAdministrativeArea: string;
|
|
8
|
+
locality: string;
|
|
9
|
+
subLocality: string;
|
|
10
|
+
thoroughfare: string;
|
|
11
|
+
subThoroughfare: string;
|
|
12
|
+
areasOfInterest: string[];
|
|
13
|
+
formatted_address: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ForwardOptions {
|
|
16
|
+
addressString: string;
|
|
17
|
+
useLocale?: boolean;
|
|
18
|
+
defaultLocale?: string;
|
|
19
|
+
maxResults?: number;
|
|
20
|
+
apiKey?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface reverseOptions {
|
|
23
|
+
latitude: number;
|
|
24
|
+
longitude: number;
|
|
25
|
+
useLocale?: boolean;
|
|
26
|
+
defaultLocale?: string;
|
|
27
|
+
maxResults?: number;
|
|
28
|
+
apiKey?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface NativeGeocoderPlugin {
|
|
31
|
+
reverseGeocode(options: reverseOptions): Promise<{
|
|
32
|
+
addresses: Adress[];
|
|
33
|
+
}>;
|
|
34
|
+
forwardGeocode(options: ForwardOptions): Promise<{
|
|
35
|
+
addresses: Adress[];
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface Adress {\n latitude:\tstring\n longitude:\tstring\n countryCode:\tstring\n postalCode:\tstring\n administrativeArea:\tstring\n subAdministrativeArea:\tstring\n locality:\tstring\n subLocality:\tstring\n thoroughfare:\tstring\n subThoroughfare:\tstring\n areasOfInterest:\tstring[]\n formatted_address: string\n}\n\nexport interface ForwardOptions {\n addressString:\tstring\n useLocale?:\tboolean\n defaultLocale?:\tstring\n maxResults?:\tnumber\n apiKey?:\tstring\n}\nexport interface reverseOptions {\n latitude:\tnumber\t\n longitude:\tnumber\n useLocale?:\tboolean\n defaultLocale?:\tstring\n maxResults?:\tnumber\n apiKey?:\tstring\n}\nexport interface NativeGeocoderPlugin {\n reverseGeocode(options: reverseOptions): Promise<{ addresses:\tAdress[] }>;\n forwardGeocode(options: ForwardOptions): Promise<{ addresses:\tAdress[] }>;\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerPlugin } from '@capacitor/core';
|
|
2
|
+
const NativeGeocoder = registerPlugin('NativeGeocoder', {
|
|
3
|
+
web: () => import('./web').then(m => new m.NativeGeocoderWeb()),
|
|
4
|
+
});
|
|
5
|
+
export * from './definitions';
|
|
6
|
+
export { NativeGeocoder };
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,cAAc,GAAG,cAAc,CAAuB,gBAAgB,EAAE;IAC5E,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;CAChE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { NativeGeocoderPlugin } from './definitions';\n\nconst NativeGeocoder = registerPlugin<NativeGeocoderPlugin>('NativeGeocoder', {\n web: () => import('./web').then(m => new m.NativeGeocoderWeb()),\n});\n\nexport * from './definitions';\nexport { NativeGeocoder };\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { NativeGeocoderPlugin, reverseOptions, ForwardOptions, Adress } from './definitions';
|
|
3
|
+
export declare class NativeGeocoderWeb extends WebPlugin implements NativeGeocoderPlugin {
|
|
4
|
+
reverseGeocode(options: reverseOptions): Promise<{
|
|
5
|
+
addresses: Adress[];
|
|
6
|
+
}>;
|
|
7
|
+
forwardGeocode(options: ForwardOptions): Promise<{
|
|
8
|
+
addresses: Adress[];
|
|
9
|
+
}>;
|
|
10
|
+
}
|
package/dist/esm/web.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
export class NativeGeocoderWeb extends WebPlugin {
|
|
3
|
+
async reverseGeocode(options) {
|
|
4
|
+
if (!options.apiKey) {
|
|
5
|
+
throw new Error('apiKey is required for web');
|
|
6
|
+
}
|
|
7
|
+
const params = Object.assign(Object.assign({ latlng: `${options.latitude},${options.longitude}`, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });
|
|
8
|
+
return fetch(`https://maps.googleapis.com/maps/api/geocode/json${new URLSearchParams(params).toString()}`)
|
|
9
|
+
.then(response => response.json())
|
|
10
|
+
.then(data => {
|
|
11
|
+
return data.results.forEach((result) => {
|
|
12
|
+
// transform the response in Adress[]
|
|
13
|
+
// use the restul from google geocoder and transform it in Adress
|
|
14
|
+
return {
|
|
15
|
+
latitude: result.geometry.location.lat,
|
|
16
|
+
longitude: result.geometry.location.lng,
|
|
17
|
+
countryCode: result.address_components[0].long_name,
|
|
18
|
+
postalCode: result.address_components[1].long_name,
|
|
19
|
+
administrativeArea: result.address_components[2].long_name,
|
|
20
|
+
subAdministrativeArea: result.address_components[3].long_name,
|
|
21
|
+
locality: result.address_components[4].long_name,
|
|
22
|
+
subLocality: result.address_components[5].long_name,
|
|
23
|
+
thoroughfare: result.address_components[6].long_name,
|
|
24
|
+
subThoroughfare: result.address_components[7].long_name,
|
|
25
|
+
areasOfInterest: result.address_components[8].long_name,
|
|
26
|
+
formatted_address: result.formatted_address,
|
|
27
|
+
};
|
|
28
|
+
}).slice(0, options.maxResults || 1);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
;
|
|
32
|
+
async forwardGeocode(options) {
|
|
33
|
+
if (!options.apiKey) {
|
|
34
|
+
throw new Error('apiKey is required for web');
|
|
35
|
+
}
|
|
36
|
+
const params = Object.assign(Object.assign({ address: options.addressString, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });
|
|
37
|
+
return fetch(`https://maps.googleapis.com/maps/api/geocode/json${new URLSearchParams(params).toString()}`)
|
|
38
|
+
.then(response => response.json())
|
|
39
|
+
.then(data => {
|
|
40
|
+
return data.results.forEach((result) => {
|
|
41
|
+
// transform the response in Adress[]
|
|
42
|
+
// use the restul from google geocoder and transform it in Adress
|
|
43
|
+
return {
|
|
44
|
+
latitude: result.geometry.location.lat,
|
|
45
|
+
longitude: result.geometry.location.lng,
|
|
46
|
+
countryCode: result.address_components[0].long_name,
|
|
47
|
+
postalCode: result.address_components[1].long_name,
|
|
48
|
+
administrativeArea: result.address_components[2].long_name,
|
|
49
|
+
subAdministrativeArea: result.address_components[3].long_name,
|
|
50
|
+
locality: result.address_components[4].long_name,
|
|
51
|
+
subLocality: result.address_components[5].long_name,
|
|
52
|
+
thoroughfare: result.address_components[6].long_name,
|
|
53
|
+
subThoroughfare: result.address_components[7].long_name,
|
|
54
|
+
areasOfInterest: result.address_components[8].long_name,
|
|
55
|
+
formatted_address: result.formatted_address,
|
|
56
|
+
};
|
|
57
|
+
}).slice(0, options.maxResults || 1);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AA8B5C,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,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,CAAC,CAAC,CAAC,CAAC,SAAS;oBAC7D,QAAQ,EAAE,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,SAAS;oBAChD,WAAW,EAAE,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,SAAS;oBACnD,YAAY,EAAE,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,SAAS;oBACpD,eAAe,EAAE,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,SAAS;oBACvD,eAAe,EAAE,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,SAAS;oBACvD,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;iBAC5C,CAAA;YACH,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC,CAAA;QACtC,CAAC,CAAC,CAAC;IACL,CAAC;IAAA,CAAC;CACP","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { NativeGeocoderPlugin, reverseOptions, ForwardOptions, Adress } from './definitions';\n\ninterface GeocoderResult {\n address_components: {\n long_name: string;\n short_name: string;\n types: string[];\n }[];\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 }\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 => {\n return data.results.forEach((result: GeocoderResult) => {\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: result.address_components[0].long_name,\n postalCode: result.address_components[1].long_name,\n administrativeArea: result.address_components[2].long_name,\n subAdministrativeArea: result.address_components[3].long_name,\n locality: result.address_components[4].long_name,\n subLocality: result.address_components[5].long_name,\n thoroughfare: result.address_components[6].long_name,\n subThoroughfare: result.address_components[7].long_name,\n areasOfInterest: result.address_components[8].long_name,\n formatted_address: result.formatted_address,\n }\n }).slice(0, options.maxResults || 1)\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 => {\n return data.results.forEach((result: GeocoderResult) => {\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: result.address_components[0].long_name,\n postalCode: result.address_components[1].long_name,\n administrativeArea: result.address_components[2].long_name,\n subAdministrativeArea: result.address_components[3].long_name,\n locality: result.address_components[4].long_name,\n subLocality: result.address_components[5].long_name,\n thoroughfare: result.address_components[6].long_name,\n subThoroughfare: result.address_components[7].long_name,\n areasOfInterest: result.address_components[8].long_name,\n formatted_address: result.formatted_address,\n }\n }).slice(0, options.maxResults || 1)\n });\n };\n}\n"]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('@capacitor/core');
|
|
6
|
+
|
|
7
|
+
const NativeGeocoder = core.registerPlugin('NativeGeocoder', {
|
|
8
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.NativeGeocoderWeb()),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
class NativeGeocoderWeb extends core.WebPlugin {
|
|
12
|
+
async reverseGeocode(options) {
|
|
13
|
+
if (!options.apiKey) {
|
|
14
|
+
throw new Error('apiKey is required for web');
|
|
15
|
+
}
|
|
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${new URLSearchParams(params).toString()}`)
|
|
18
|
+
.then(response => response.json())
|
|
19
|
+
.then(data => {
|
|
20
|
+
return data.results.forEach((result) => {
|
|
21
|
+
// transform the response in Adress[]
|
|
22
|
+
// use the restul from google geocoder and transform it in Adress
|
|
23
|
+
return {
|
|
24
|
+
latitude: result.geometry.location.lat,
|
|
25
|
+
longitude: result.geometry.location.lng,
|
|
26
|
+
countryCode: result.address_components[0].long_name,
|
|
27
|
+
postalCode: result.address_components[1].long_name,
|
|
28
|
+
administrativeArea: result.address_components[2].long_name,
|
|
29
|
+
subAdministrativeArea: result.address_components[3].long_name,
|
|
30
|
+
locality: result.address_components[4].long_name,
|
|
31
|
+
subLocality: result.address_components[5].long_name,
|
|
32
|
+
thoroughfare: result.address_components[6].long_name,
|
|
33
|
+
subThoroughfare: result.address_components[7].long_name,
|
|
34
|
+
areasOfInterest: result.address_components[8].long_name,
|
|
35
|
+
formatted_address: result.formatted_address,
|
|
36
|
+
};
|
|
37
|
+
}).slice(0, options.maxResults || 1);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
;
|
|
41
|
+
async forwardGeocode(options) {
|
|
42
|
+
if (!options.apiKey) {
|
|
43
|
+
throw new Error('apiKey is required for web');
|
|
44
|
+
}
|
|
45
|
+
const params = Object.assign(Object.assign({ address: options.addressString, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });
|
|
46
|
+
return fetch(`https://maps.googleapis.com/maps/api/geocode/json${new URLSearchParams(params).toString()}`)
|
|
47
|
+
.then(response => response.json())
|
|
48
|
+
.then(data => {
|
|
49
|
+
return data.results.forEach((result) => {
|
|
50
|
+
// transform the response in Adress[]
|
|
51
|
+
// use the restul from google geocoder and transform it in Adress
|
|
52
|
+
return {
|
|
53
|
+
latitude: result.geometry.location.lat,
|
|
54
|
+
longitude: result.geometry.location.lng,
|
|
55
|
+
countryCode: result.address_components[0].long_name,
|
|
56
|
+
postalCode: result.address_components[1].long_name,
|
|
57
|
+
administrativeArea: result.address_components[2].long_name,
|
|
58
|
+
subAdministrativeArea: result.address_components[3].long_name,
|
|
59
|
+
locality: result.address_components[4].long_name,
|
|
60
|
+
subLocality: result.address_components[5].long_name,
|
|
61
|
+
thoroughfare: result.address_components[6].long_name,
|
|
62
|
+
subThoroughfare: result.address_components[7].long_name,
|
|
63
|
+
areasOfInterest: result.address_components[8].long_name,
|
|
64
|
+
formatted_address: result.formatted_address,
|
|
65
|
+
};
|
|
66
|
+
}).slice(0, options.maxResults || 1);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
73
|
+
__proto__: null,
|
|
74
|
+
NativeGeocoderWeb: NativeGeocoderWeb
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
exports.NativeGeocoder = NativeGeocoder;
|
|
78
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +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';\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 data.results.forEach((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: result.address_components[0].long_name,\n postalCode: result.address_components[1].long_name,\n administrativeArea: result.address_components[2].long_name,\n subAdministrativeArea: result.address_components[3].long_name,\n locality: result.address_components[4].long_name,\n subLocality: result.address_components[5].long_name,\n thoroughfare: result.address_components[6].long_name,\n subThoroughfare: result.address_components[7].long_name,\n areasOfInterest: result.address_components[8].long_name,\n formatted_address: result.formatted_address,\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 data.results.forEach((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: result.address_components[0].long_name,\n postalCode: result.address_components[1].long_name,\n administrativeArea: result.address_components[2].long_name,\n subAdministrativeArea: result.address_components[3].long_name,\n locality: result.address_components[4].long_name,\n subLocality: result.address_components[5].long_name,\n thoroughfare: result.address_components[6].long_name,\n subThoroughfare: result.address_components[7].long_name,\n areasOfInterest: result.address_components[8].long_name,\n formatted_address: result.formatted_address,\n };\n }).slice(0, options.maxResults || 1);\n });\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AAC,CAAC,SAAS;AAC3E,oBAAoB,eAAe,EAAE,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,SAAS;AAC3E,oBAAoB,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;AAC/D,iBAAiB,CAAC;AAClB,aAAa,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC;AACjD,SAAS,CAAC,CAAC;AACX,KAAK;AACL;AACA;;;;;;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
var capacitorNativeGeocoder = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const NativeGeocoder = core.registerPlugin('NativeGeocoder', {
|
|
5
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.NativeGeocoderWeb()),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
class NativeGeocoderWeb extends core.WebPlugin {
|
|
9
|
+
async reverseGeocode(options) {
|
|
10
|
+
if (!options.apiKey) {
|
|
11
|
+
throw new Error('apiKey is required for web');
|
|
12
|
+
}
|
|
13
|
+
const params = Object.assign(Object.assign({ latlng: `${options.latitude},${options.longitude}`, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });
|
|
14
|
+
return fetch(`https://maps.googleapis.com/maps/api/geocode/json${new URLSearchParams(params).toString()}`)
|
|
15
|
+
.then(response => response.json())
|
|
16
|
+
.then(data => {
|
|
17
|
+
return data.results.forEach((result) => {
|
|
18
|
+
// transform the response in Adress[]
|
|
19
|
+
// use the restul from google geocoder and transform it in Adress
|
|
20
|
+
return {
|
|
21
|
+
latitude: result.geometry.location.lat,
|
|
22
|
+
longitude: result.geometry.location.lng,
|
|
23
|
+
countryCode: result.address_components[0].long_name,
|
|
24
|
+
postalCode: result.address_components[1].long_name,
|
|
25
|
+
administrativeArea: result.address_components[2].long_name,
|
|
26
|
+
subAdministrativeArea: result.address_components[3].long_name,
|
|
27
|
+
locality: result.address_components[4].long_name,
|
|
28
|
+
subLocality: result.address_components[5].long_name,
|
|
29
|
+
thoroughfare: result.address_components[6].long_name,
|
|
30
|
+
subThoroughfare: result.address_components[7].long_name,
|
|
31
|
+
areasOfInterest: result.address_components[8].long_name,
|
|
32
|
+
formatted_address: result.formatted_address,
|
|
33
|
+
};
|
|
34
|
+
}).slice(0, options.maxResults || 1);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
;
|
|
38
|
+
async forwardGeocode(options) {
|
|
39
|
+
if (!options.apiKey) {
|
|
40
|
+
throw new Error('apiKey is required for web');
|
|
41
|
+
}
|
|
42
|
+
const params = Object.assign(Object.assign({ address: options.addressString, key: options.apiKey }, (options.defaultLocale && { language: options.defaultLocale })), { result_type: 'street_address' });
|
|
43
|
+
return fetch(`https://maps.googleapis.com/maps/api/geocode/json${new URLSearchParams(params).toString()}`)
|
|
44
|
+
.then(response => response.json())
|
|
45
|
+
.then(data => {
|
|
46
|
+
return data.results.forEach((result) => {
|
|
47
|
+
// transform the response in Adress[]
|
|
48
|
+
// use the restul from google geocoder and transform it in Adress
|
|
49
|
+
return {
|
|
50
|
+
latitude: result.geometry.location.lat,
|
|
51
|
+
longitude: result.geometry.location.lng,
|
|
52
|
+
countryCode: result.address_components[0].long_name,
|
|
53
|
+
postalCode: result.address_components[1].long_name,
|
|
54
|
+
administrativeArea: result.address_components[2].long_name,
|
|
55
|
+
subAdministrativeArea: result.address_components[3].long_name,
|
|
56
|
+
locality: result.address_components[4].long_name,
|
|
57
|
+
subLocality: result.address_components[5].long_name,
|
|
58
|
+
thoroughfare: result.address_components[6].long_name,
|
|
59
|
+
subThoroughfare: result.address_components[7].long_name,
|
|
60
|
+
areasOfInterest: result.address_components[8].long_name,
|
|
61
|
+
formatted_address: result.formatted_address,
|
|
62
|
+
};
|
|
63
|
+
}).slice(0, options.maxResults || 1);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
70
|
+
__proto__: null,
|
|
71
|
+
NativeGeocoderWeb: NativeGeocoderWeb
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
exports.NativeGeocoder = NativeGeocoder;
|
|
75
|
+
|
|
76
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
77
|
+
|
|
78
|
+
return exports;
|
|
79
|
+
|
|
80
|
+
})({}, capacitorExports);
|
|
81
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +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';\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 data.results.forEach((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: result.address_components[0].long_name,\n postalCode: result.address_components[1].long_name,\n administrativeArea: result.address_components[2].long_name,\n subAdministrativeArea: result.address_components[3].long_name,\n locality: result.address_components[4].long_name,\n subLocality: result.address_components[5].long_name,\n thoroughfare: result.address_components[6].long_name,\n subThoroughfare: result.address_components[7].long_name,\n areasOfInterest: result.address_components[8].long_name,\n formatted_address: result.formatted_address,\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 data.results.forEach((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: result.address_components[0].long_name,\n postalCode: result.address_components[1].long_name,\n administrativeArea: result.address_components[2].long_name,\n subAdministrativeArea: result.address_components[3].long_name,\n locality: result.address_components[4].long_name,\n subLocality: result.address_components[5].long_name,\n thoroughfare: result.address_components[6].long_name,\n subThoroughfare: result.address_components[7].long_name,\n areasOfInterest: result.address_components[8].long_name,\n formatted_address: result.formatted_address,\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,IAAI,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;IACnE,CAAC;;ICFM,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,S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GE)</string>
|
|
7
|
+
<key>CFBundleExecutable</key>
|
|
8
|
+
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
+
<key>CFBundleIdentifier</key>
|
|
10
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
+
<string>6.0</string>
|
|
13
|
+
<key>CFBundleName</key>
|
|
14
|
+
<string>$(PRODUCT_NAME)</string>
|
|
15
|
+
<key>CFBundlePackageType</key>
|
|
16
|
+
<string>FMWK</string>
|
|
17
|
+
<key>CFBundleShortVersionString</key>
|
|
18
|
+
<string>1.0</string>
|
|
19
|
+
<key>CFBundleVersion</key>
|
|
20
|
+
<string>$(CURRENT_PROJECT_VERSION)</string>
|
|
21
|
+
<key>NSPrincipalClass</key>
|
|
22
|
+
<string></string>
|
|
23
|
+
</dict>
|
|
24
|
+
</plist>
|