@capgo/capacitor-nativegeocoder 8.0.32
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/CapgoCapacitorNativegeocoder.podspec +17 -0
- package/LICENSE +373 -0
- package/Package.swift +28 -0
- package/README.md +180 -0
- package/android/build.gradle +59 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/ee/forgr/capacitor_nativegeocoder/NativeGeocoder.java +229 -0
- package/android/src/main/java/ee/forgr/capacitor_nativegeocoder/NativeGeocoderPlugin.java +53 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +298 -0
- package/dist/esm/definitions.d.ts +98 -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 +13 -0
- package/dist/esm/web.js +78 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +92 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +95 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/NativeGeocoderPlugin/NativeGeocoder.swift +194 -0
- package/ios/Sources/NativeGeocoderPlugin/NativeGeocoderPlugin.swift +44 -0
- package/ios/Tests/NativeGeocoderPluginTests/NativeGeocoderTests.swift +16 -0
- package/package.json +88 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
package ee.forgr.capacitor_nativegeocoder;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.location.Address;
|
|
5
|
+
import android.location.Geocoder;
|
|
6
|
+
import android.net.ConnectivityManager;
|
|
7
|
+
import android.net.NetworkInfo;
|
|
8
|
+
import com.getcapacitor.JSObject;
|
|
9
|
+
import com.getcapacitor.PluginCall;
|
|
10
|
+
import java.util.List;
|
|
11
|
+
import java.util.Locale;
|
|
12
|
+
import org.json.JSONArray;
|
|
13
|
+
import org.json.JSONObject;
|
|
14
|
+
|
|
15
|
+
class NativeGeocoderOptions {
|
|
16
|
+
|
|
17
|
+
boolean useLocale = true;
|
|
18
|
+
String defaultLocale = null;
|
|
19
|
+
int maxResults = 1;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public class NativeGeocoder {
|
|
23
|
+
|
|
24
|
+
private Geocoder geocoder;
|
|
25
|
+
public Context context;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Reverse geocode a given latitude and longitude to find location address
|
|
29
|
+
* @param latitude double
|
|
30
|
+
* @param longitude double
|
|
31
|
+
* @param call PluginCall
|
|
32
|
+
*/
|
|
33
|
+
public void reverseGeocode(double latitude, double longitude, PluginCall call) {
|
|
34
|
+
if (latitude == 0 || longitude == 0) {
|
|
35
|
+
call.reject("Expected two non-empty double arguments.");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!Geocoder.isPresent()) {
|
|
40
|
+
call.reject("Geocoder is not present on this device/emulator.");
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
NativeGeocoderOptions geocoderOptions = getNativeGeocoderOptions(call);
|
|
45
|
+
geocoder = createGeocoderWithOptions(geocoderOptions);
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
List<Address> geoResults = geocoder.getFromLocation(latitude, longitude, geocoderOptions.maxResults);
|
|
49
|
+
if (geoResults.size() > 0) {
|
|
50
|
+
int maxResultObjects = geoResults.size() >= geocoderOptions.maxResults ? geoResults.size() : geoResults.size();
|
|
51
|
+
JSONArray resultObj = new JSONArray();
|
|
52
|
+
|
|
53
|
+
for (int i = 0; i < maxResultObjects; i++) {
|
|
54
|
+
Address address = geoResults.get(i);
|
|
55
|
+
|
|
56
|
+
// https://developer.android.com/reference/android/location/Address.html
|
|
57
|
+
JSONObject placemark = new JSONObject();
|
|
58
|
+
placemark.put("latitude", !String.valueOf(address.getLatitude()).isEmpty() ? address.getLatitude() : 0);
|
|
59
|
+
placemark.put("longitude", !String.valueOf(address.getLongitude()).isEmpty() ? address.getLongitude() : 0);
|
|
60
|
+
placemark.put("countryCode", address.getCountryCode() != null ? address.getCountryCode() : "");
|
|
61
|
+
placemark.put("countryName", address.getCountryName() != null ? address.getCountryName() : "");
|
|
62
|
+
placemark.put("postalCode", address.getPostalCode() != null ? address.getPostalCode() : "");
|
|
63
|
+
placemark.put("administrativeArea", address.getAdminArea() != null ? address.getAdminArea() : "");
|
|
64
|
+
placemark.put("subAdministrativeArea", address.getSubAdminArea() != null ? address.getSubAdminArea() : "");
|
|
65
|
+
placemark.put("locality", address.getLocality() != null ? address.getLocality() : "");
|
|
66
|
+
placemark.put("subLocality", address.getSubLocality() != null ? address.getSubLocality() : "");
|
|
67
|
+
placemark.put("thoroughfare", address.getThoroughfare() != null ? address.getThoroughfare() : "");
|
|
68
|
+
placemark.put("subThoroughfare", address.getSubThoroughfare() != null ? address.getSubThoroughfare() : "");
|
|
69
|
+
placemark.put(
|
|
70
|
+
"areasOfInterest",
|
|
71
|
+
address.getFeatureName() != null ? new JSONArray(new String[] { address.getFeatureName() }) : new JSONArray()
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
resultObj.put(placemark);
|
|
75
|
+
}
|
|
76
|
+
JSObject ret = new JSObject();
|
|
77
|
+
ret.put("addresses", resultObj);
|
|
78
|
+
call.resolve(ret);
|
|
79
|
+
} else {
|
|
80
|
+
call.reject("Cannot get an address.");
|
|
81
|
+
}
|
|
82
|
+
} catch (Exception e) {
|
|
83
|
+
String errorMsg = e.getMessage();
|
|
84
|
+
if (e.getMessage().equals("grpc failed") && !isNetworkAvailable()) {
|
|
85
|
+
errorMsg = "No Internet Access";
|
|
86
|
+
}
|
|
87
|
+
call.reject("Geocoder:getFromLocationName Error: " + errorMsg);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Forward geocode a given address to find coordinates
|
|
93
|
+
* @param addressString String
|
|
94
|
+
* @param call PluginCall
|
|
95
|
+
*/
|
|
96
|
+
public void forwardGeocode(String addressString, PluginCall call) {
|
|
97
|
+
if (addressString == null || addressString.length() == 0) {
|
|
98
|
+
call.reject("Expected a non-empty string argument.");
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (!Geocoder.isPresent()) {
|
|
103
|
+
call.reject("Geocoder is not present on this device/emulator.");
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
NativeGeocoderOptions geocoderOptions = getNativeGeocoderOptions(call);
|
|
108
|
+
geocoder = createGeocoderWithOptions(geocoderOptions);
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
List<Address> geoResults = geocoder.getFromLocationName(addressString, geocoderOptions.maxResults);
|
|
112
|
+
|
|
113
|
+
if (geoResults.size() > 0) {
|
|
114
|
+
int maxResultObjects = geoResults.size() >= geocoderOptions.maxResults ? geoResults.size() : geoResults.size();
|
|
115
|
+
JSONArray resultObj = new JSONArray();
|
|
116
|
+
|
|
117
|
+
for (int i = 0; i < maxResultObjects; i++) {
|
|
118
|
+
Address address = geoResults.get(i);
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
String latitude = String.valueOf(address.getLatitude());
|
|
122
|
+
String longitude = String.valueOf(address.getLongitude());
|
|
123
|
+
|
|
124
|
+
if (!latitude.isEmpty() && !longitude.isEmpty()) {
|
|
125
|
+
// https://developer.android.com/reference/android/location/Address.html
|
|
126
|
+
JSObject placemark = new JSObject();
|
|
127
|
+
placemark.put("latitude", address.getLatitude());
|
|
128
|
+
placemark.put("longitude", address.getLongitude());
|
|
129
|
+
placemark.put("countryCode", address.getCountryCode() != null ? address.getCountryCode() : "");
|
|
130
|
+
placemark.put("countryName", address.getCountryName() != null ? address.getCountryName() : "");
|
|
131
|
+
placemark.put("postalCode", address.getPostalCode() != null ? address.getPostalCode() : "");
|
|
132
|
+
placemark.put("administrativeArea", address.getAdminArea() != null ? address.getAdminArea() : "");
|
|
133
|
+
placemark.put("subAdministrativeArea", address.getSubAdminArea() != null ? address.getSubAdminArea() : "");
|
|
134
|
+
placemark.put("locality", address.getLocality() != null ? address.getLocality() : "");
|
|
135
|
+
placemark.put("subLocality", address.getSubLocality() != null ? address.getSubLocality() : "");
|
|
136
|
+
placemark.put("thoroughfare", address.getThoroughfare() != null ? address.getThoroughfare() : "");
|
|
137
|
+
placemark.put("subThoroughfare", address.getSubThoroughfare() != null ? address.getSubThoroughfare() : "");
|
|
138
|
+
placemark.put(
|
|
139
|
+
"areasOfInterest",
|
|
140
|
+
address.getFeatureName() != null
|
|
141
|
+
? new JSONArray(new String[] { address.getFeatureName() })
|
|
142
|
+
: new JSONArray()
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
resultObj.put(placemark);
|
|
146
|
+
}
|
|
147
|
+
} catch (RuntimeException e) {
|
|
148
|
+
e.printStackTrace();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (resultObj.length() == 0) {
|
|
153
|
+
call.reject("Cannot get latitude and/or longitude.");
|
|
154
|
+
} else {
|
|
155
|
+
JSObject ret = new JSObject();
|
|
156
|
+
ret.put("addresses", resultObj);
|
|
157
|
+
call.resolve(ret);
|
|
158
|
+
}
|
|
159
|
+
} else {
|
|
160
|
+
call.reject("Cannot find a location.");
|
|
161
|
+
}
|
|
162
|
+
} catch (Exception e) {
|
|
163
|
+
String errorMsg = e.getMessage();
|
|
164
|
+
if (e.getMessage().equals("grpc failed") && !isNetworkAvailable()) {
|
|
165
|
+
errorMsg = "No Internet Access";
|
|
166
|
+
}
|
|
167
|
+
call.reject("Geocoder:getFromLocationName Error: " + errorMsg);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Get network connection
|
|
173
|
+
* @return boolean
|
|
174
|
+
*/
|
|
175
|
+
private boolean isNetworkAvailable() {
|
|
176
|
+
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
177
|
+
NetworkInfo activeNetworkInfo = null;
|
|
178
|
+
if (connectivityManager != null) {
|
|
179
|
+
activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
|
|
180
|
+
}
|
|
181
|
+
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Get a valid NativeGeocoderOptions object
|
|
186
|
+
* @param options JSONObject
|
|
187
|
+
* @return NativeGeocoderOptions
|
|
188
|
+
*/
|
|
189
|
+
private NativeGeocoderOptions getNativeGeocoderOptions(PluginCall options) {
|
|
190
|
+
NativeGeocoderOptions geocoderOptions = new NativeGeocoderOptions();
|
|
191
|
+
|
|
192
|
+
if (options != null) {
|
|
193
|
+
geocoderOptions.useLocale = options.getBoolean("useLocale", false);
|
|
194
|
+
geocoderOptions.defaultLocale = options.getString("defaultLocale", null);
|
|
195
|
+
geocoderOptions.maxResults = options.getInt("maxResults", 1);
|
|
196
|
+
if (geocoderOptions.maxResults > 0) {
|
|
197
|
+
int MAX_RESULTS_COUNT = 5;
|
|
198
|
+
geocoderOptions.maxResults = Math.min(geocoderOptions.maxResults, MAX_RESULTS_COUNT);
|
|
199
|
+
} else {
|
|
200
|
+
geocoderOptions.maxResults = 1;
|
|
201
|
+
}
|
|
202
|
+
} else {
|
|
203
|
+
geocoderOptions.useLocale = true;
|
|
204
|
+
geocoderOptions.defaultLocale = null;
|
|
205
|
+
geocoderOptions.maxResults = 1;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return geocoderOptions;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Create a Geocoder with NativeGeocoderOptions
|
|
213
|
+
* @param geocoderOptions NativeGeocoderOptions
|
|
214
|
+
* @return Geocoder
|
|
215
|
+
*/
|
|
216
|
+
private Geocoder createGeocoderWithOptions(NativeGeocoderOptions geocoderOptions) {
|
|
217
|
+
if (geocoderOptions.defaultLocale != null && !geocoderOptions.defaultLocale.isEmpty()) {
|
|
218
|
+
Locale locale = Locale.forLanguageTag(geocoderOptions.defaultLocale);
|
|
219
|
+
geocoder = new Geocoder(context.getApplicationContext(), locale);
|
|
220
|
+
} else {
|
|
221
|
+
if (geocoderOptions.useLocale) {
|
|
222
|
+
geocoder = new Geocoder(context.getApplicationContext(), Locale.getDefault());
|
|
223
|
+
} else {
|
|
224
|
+
geocoder = new Geocoder(context.getApplicationContext(), Locale.ENGLISH);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return geocoder;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
package ee.forgr.capacitor_nativegeocoder;
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.JSObject;
|
|
4
|
+
import com.getcapacitor.Plugin;
|
|
5
|
+
import com.getcapacitor.PluginCall;
|
|
6
|
+
import com.getcapacitor.PluginMethod;
|
|
7
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
8
|
+
|
|
9
|
+
@CapacitorPlugin(name = "NativeGeocoder")
|
|
10
|
+
public class NativeGeocoderPlugin extends Plugin {
|
|
11
|
+
|
|
12
|
+
private final String pluginVersion = "8.0.32";
|
|
13
|
+
|
|
14
|
+
private NativeGeocoder implementation = new NativeGeocoder();
|
|
15
|
+
|
|
16
|
+
@Override
|
|
17
|
+
public void load() {
|
|
18
|
+
super.load();
|
|
19
|
+
implementation.context = this.getContext();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@PluginMethod
|
|
23
|
+
public void reverseGeocode(PluginCall call) {
|
|
24
|
+
Double latitude = call.getDouble("latitude");
|
|
25
|
+
Double longitude = call.getDouble("longitude");
|
|
26
|
+
if (latitude == null || longitude == null) {
|
|
27
|
+
call.reject("Missing latitude or longitude");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
implementation.reverseGeocode(latitude, longitude, call);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@PluginMethod
|
|
34
|
+
public void forwardGeocode(PluginCall call) {
|
|
35
|
+
String addressString = call.getString("addressString");
|
|
36
|
+
if (addressString == null) {
|
|
37
|
+
call.reject("Missing addressString");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
implementation.forwardGeocode(addressString, call);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@PluginMethod
|
|
44
|
+
public void getPluginVersion(final PluginCall call) {
|
|
45
|
+
try {
|
|
46
|
+
final JSObject ret = new JSObject();
|
|
47
|
+
ret.put("version", this.pluginVersion);
|
|
48
|
+
call.resolve(ret);
|
|
49
|
+
} catch (final Exception e) {
|
|
50
|
+
call.reject("Could not get plugin version", e);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
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: Address[]; }>",
|
|
11
|
+
"parameters": [
|
|
12
|
+
{
|
|
13
|
+
"name": "options",
|
|
14
|
+
"docs": "",
|
|
15
|
+
"type": "ReverseOptions"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"returns": "Promise<{ addresses: Address[]; }>",
|
|
19
|
+
"tags": [
|
|
20
|
+
{
|
|
21
|
+
"name": "param",
|
|
22
|
+
"text": "id The bundle id to delete (note, this is the bundle id, NOT the version name)"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "returns",
|
|
26
|
+
"text": "an Promise with the list of addresses according to maxResults"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "throws",
|
|
30
|
+
"text": "An error if the something went wrong"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "since",
|
|
34
|
+
"text": "0.0.1"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"docs": "Convert latitude and longitude to an address",
|
|
38
|
+
"complexTypes": [
|
|
39
|
+
"Address",
|
|
40
|
+
"ReverseOptions"
|
|
41
|
+
],
|
|
42
|
+
"slug": "reversegeocode"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "forwardGeocode",
|
|
46
|
+
"signature": "(options: ForwardOptions) => Promise<{ addresses: Address[]; }>",
|
|
47
|
+
"parameters": [
|
|
48
|
+
{
|
|
49
|
+
"name": "options",
|
|
50
|
+
"docs": "",
|
|
51
|
+
"type": "ForwardOptions"
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"returns": "Promise<{ addresses: Address[]; }>",
|
|
55
|
+
"tags": [
|
|
56
|
+
{
|
|
57
|
+
"name": "returns",
|
|
58
|
+
"text": "an Promise with the list of addresses according to maxResults"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"name": "throws",
|
|
62
|
+
"text": "An error if the something went wrong"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "since",
|
|
66
|
+
"text": "0.0.1"
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"docs": "Convert an address to latitude and longitude",
|
|
70
|
+
"complexTypes": [
|
|
71
|
+
"Address",
|
|
72
|
+
"ForwardOptions"
|
|
73
|
+
],
|
|
74
|
+
"slug": "forwardgeocode"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"name": "getPluginVersion",
|
|
78
|
+
"signature": "() => Promise<{ version: string; }>",
|
|
79
|
+
"parameters": [],
|
|
80
|
+
"returns": "Promise<{ version: string; }>",
|
|
81
|
+
"tags": [
|
|
82
|
+
{
|
|
83
|
+
"name": "returns",
|
|
84
|
+
"text": "an Promise with version for this device"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"name": "throws",
|
|
88
|
+
"text": "An error if the something went wrong"
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
"docs": "Get the native Capacitor plugin version",
|
|
92
|
+
"complexTypes": [],
|
|
93
|
+
"slug": "getpluginversion"
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
"properties": []
|
|
97
|
+
},
|
|
98
|
+
"interfaces": [
|
|
99
|
+
{
|
|
100
|
+
"name": "Address",
|
|
101
|
+
"slug": "address",
|
|
102
|
+
"docs": "",
|
|
103
|
+
"tags": [],
|
|
104
|
+
"methods": [],
|
|
105
|
+
"properties": [
|
|
106
|
+
{
|
|
107
|
+
"name": "latitude",
|
|
108
|
+
"tags": [],
|
|
109
|
+
"docs": "",
|
|
110
|
+
"complexTypes": [],
|
|
111
|
+
"type": "number"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"name": "longitude",
|
|
115
|
+
"tags": [],
|
|
116
|
+
"docs": "",
|
|
117
|
+
"complexTypes": [],
|
|
118
|
+
"type": "number"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"name": "countryCode",
|
|
122
|
+
"tags": [],
|
|
123
|
+
"docs": "",
|
|
124
|
+
"complexTypes": [],
|
|
125
|
+
"type": "string"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"name": "countryName",
|
|
129
|
+
"tags": [],
|
|
130
|
+
"docs": "",
|
|
131
|
+
"complexTypes": [],
|
|
132
|
+
"type": "string"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"name": "postalCode",
|
|
136
|
+
"tags": [],
|
|
137
|
+
"docs": "",
|
|
138
|
+
"complexTypes": [],
|
|
139
|
+
"type": "string"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"name": "administrativeArea",
|
|
143
|
+
"tags": [],
|
|
144
|
+
"docs": "",
|
|
145
|
+
"complexTypes": [],
|
|
146
|
+
"type": "string"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"name": "subAdministrativeArea",
|
|
150
|
+
"tags": [],
|
|
151
|
+
"docs": "",
|
|
152
|
+
"complexTypes": [],
|
|
153
|
+
"type": "string"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"name": "locality",
|
|
157
|
+
"tags": [],
|
|
158
|
+
"docs": "",
|
|
159
|
+
"complexTypes": [],
|
|
160
|
+
"type": "string"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"name": "subLocality",
|
|
164
|
+
"tags": [],
|
|
165
|
+
"docs": "",
|
|
166
|
+
"complexTypes": [],
|
|
167
|
+
"type": "string"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"name": "thoroughfare",
|
|
171
|
+
"tags": [],
|
|
172
|
+
"docs": "",
|
|
173
|
+
"complexTypes": [],
|
|
174
|
+
"type": "string"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"name": "subThoroughfare",
|
|
178
|
+
"tags": [],
|
|
179
|
+
"docs": "",
|
|
180
|
+
"complexTypes": [],
|
|
181
|
+
"type": "string"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"name": "areasOfInterest",
|
|
185
|
+
"tags": [],
|
|
186
|
+
"docs": "",
|
|
187
|
+
"complexTypes": [],
|
|
188
|
+
"type": "string[]"
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"name": "ReverseOptions",
|
|
194
|
+
"slug": "reverseoptions",
|
|
195
|
+
"docs": "",
|
|
196
|
+
"tags": [],
|
|
197
|
+
"methods": [],
|
|
198
|
+
"properties": [
|
|
199
|
+
{
|
|
200
|
+
"name": "latitude",
|
|
201
|
+
"tags": [],
|
|
202
|
+
"docs": "latitude is a number representing the latitude of the location.",
|
|
203
|
+
"complexTypes": [],
|
|
204
|
+
"type": "number"
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"name": "longitude",
|
|
208
|
+
"tags": [],
|
|
209
|
+
"docs": "longitude is a number representing the longitude of the location.",
|
|
210
|
+
"complexTypes": [],
|
|
211
|
+
"type": "number"
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"name": "useLocale",
|
|
215
|
+
"tags": [],
|
|
216
|
+
"docs": "Localise the results to the given locale.",
|
|
217
|
+
"complexTypes": [],
|
|
218
|
+
"type": "boolean | undefined"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"name": "defaultLocale",
|
|
222
|
+
"tags": [],
|
|
223
|
+
"docs": "locale is a string in the format of language_country, for example en_US.",
|
|
224
|
+
"complexTypes": [],
|
|
225
|
+
"type": "string | undefined"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"name": "maxResults",
|
|
229
|
+
"tags": [],
|
|
230
|
+
"docs": "Max number of results to return.",
|
|
231
|
+
"complexTypes": [],
|
|
232
|
+
"type": "number | undefined"
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"name": "apiKey",
|
|
236
|
+
"tags": [],
|
|
237
|
+
"docs": "Only used for web platform to use google api",
|
|
238
|
+
"complexTypes": [],
|
|
239
|
+
"type": "string | undefined"
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
"name": "resultType",
|
|
243
|
+
"tags": [],
|
|
244
|
+
"docs": "Only used for web platform to use google api",
|
|
245
|
+
"complexTypes": [],
|
|
246
|
+
"type": "string | undefined"
|
|
247
|
+
}
|
|
248
|
+
]
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"name": "ForwardOptions",
|
|
252
|
+
"slug": "forwardoptions",
|
|
253
|
+
"docs": "",
|
|
254
|
+
"tags": [],
|
|
255
|
+
"methods": [],
|
|
256
|
+
"properties": [
|
|
257
|
+
{
|
|
258
|
+
"name": "addressString",
|
|
259
|
+
"tags": [],
|
|
260
|
+
"docs": "address is a string of the address to be geocoded.",
|
|
261
|
+
"complexTypes": [],
|
|
262
|
+
"type": "string"
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
"name": "useLocale",
|
|
266
|
+
"tags": [],
|
|
267
|
+
"docs": "Localise the results to the given locale.",
|
|
268
|
+
"complexTypes": [],
|
|
269
|
+
"type": "boolean | undefined"
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"name": "defaultLocale",
|
|
273
|
+
"tags": [],
|
|
274
|
+
"docs": "locale is a string in the format of language_country, for example en_US.",
|
|
275
|
+
"complexTypes": [],
|
|
276
|
+
"type": "string | undefined"
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
"name": "maxResults",
|
|
280
|
+
"tags": [],
|
|
281
|
+
"docs": "Max number of results to return.",
|
|
282
|
+
"complexTypes": [],
|
|
283
|
+
"type": "number | undefined"
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
"name": "apiKey",
|
|
287
|
+
"tags": [],
|
|
288
|
+
"docs": "Only used for web platform to use google api",
|
|
289
|
+
"complexTypes": [],
|
|
290
|
+
"type": "string | undefined"
|
|
291
|
+
}
|
|
292
|
+
]
|
|
293
|
+
}
|
|
294
|
+
],
|
|
295
|
+
"enums": [],
|
|
296
|
+
"typeAliases": [],
|
|
297
|
+
"pluginConfigs": []
|
|
298
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export interface Address {
|
|
2
|
+
latitude: number;
|
|
3
|
+
longitude: number;
|
|
4
|
+
countryCode: string;
|
|
5
|
+
countryName: string;
|
|
6
|
+
postalCode: string;
|
|
7
|
+
administrativeArea: string;
|
|
8
|
+
subAdministrativeArea: string;
|
|
9
|
+
locality: string;
|
|
10
|
+
subLocality: string;
|
|
11
|
+
thoroughfare: string;
|
|
12
|
+
subThoroughfare: string;
|
|
13
|
+
areasOfInterest: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface ForwardOptions {
|
|
16
|
+
/**
|
|
17
|
+
* address is a string of the address to be geocoded.
|
|
18
|
+
*/
|
|
19
|
+
addressString: string;
|
|
20
|
+
/**
|
|
21
|
+
* Localise the results to the given locale.
|
|
22
|
+
*/
|
|
23
|
+
useLocale?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* locale is a string in the format of language_country, for example en_US.
|
|
26
|
+
*/
|
|
27
|
+
defaultLocale?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Max number of results to return.
|
|
30
|
+
*/
|
|
31
|
+
maxResults?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Only used for web platform to use google api
|
|
34
|
+
*/
|
|
35
|
+
apiKey?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface ReverseOptions {
|
|
38
|
+
/**
|
|
39
|
+
* latitude is a number representing the latitude of the location.
|
|
40
|
+
*/
|
|
41
|
+
latitude: number;
|
|
42
|
+
/**
|
|
43
|
+
* longitude is a number representing the longitude of the location.
|
|
44
|
+
*/
|
|
45
|
+
longitude: number;
|
|
46
|
+
/**
|
|
47
|
+
* Localise the results to the given locale.
|
|
48
|
+
*/
|
|
49
|
+
useLocale?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* locale is a string in the format of language_country, for example en_US.
|
|
52
|
+
*/
|
|
53
|
+
defaultLocale?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Max number of results to return.
|
|
56
|
+
*/
|
|
57
|
+
maxResults?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Only used for web platform to use google api
|
|
60
|
+
*/
|
|
61
|
+
apiKey?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Only used for web platform to use google api
|
|
64
|
+
*/
|
|
65
|
+
resultType?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface NativeGeocoderPlugin {
|
|
68
|
+
/**
|
|
69
|
+
* Convert latitude and longitude to an address
|
|
70
|
+
*
|
|
71
|
+
* @param id The bundle id to delete (note, this is the bundle id, NOT the version name)
|
|
72
|
+
* @returns {Promise<{addresses: Address[]}>} an Promise with the list of addresses according to maxResults
|
|
73
|
+
* @throws An error if the something went wrong
|
|
74
|
+
* @since 0.0.1
|
|
75
|
+
*/
|
|
76
|
+
reverseGeocode(options: ReverseOptions): Promise<{
|
|
77
|
+
addresses: Address[];
|
|
78
|
+
}>;
|
|
79
|
+
/**
|
|
80
|
+
* Convert an address to latitude and longitude
|
|
81
|
+
*
|
|
82
|
+
* @returns {Promise<{addresses: Address[]}>} an Promise with the list of addresses according to maxResults
|
|
83
|
+
* @throws An error if the something went wrong
|
|
84
|
+
* @since 0.0.1
|
|
85
|
+
*/
|
|
86
|
+
forwardGeocode(options: ForwardOptions): Promise<{
|
|
87
|
+
addresses: Address[];
|
|
88
|
+
}>;
|
|
89
|
+
/**
|
|
90
|
+
* Get the native Capacitor plugin version
|
|
91
|
+
*
|
|
92
|
+
* @returns {Promise<{ id: string }>} an Promise with version for this device
|
|
93
|
+
* @throws An error if the something went wrong
|
|
94
|
+
*/
|
|
95
|
+
getPluginVersion(): Promise<{
|
|
96
|
+
version: string;
|
|
97
|
+
}>;
|
|
98
|
+
}
|
|
@@ -0,0 +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 /**\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 /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n"]}
|