@capgo/nativegeocoder 0.1.9 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -32,7 +32,7 @@ public class NativeGeocoder {
|
|
|
32
32
|
* @param longitude double
|
|
33
33
|
* @param call PluginCall
|
|
34
34
|
*/
|
|
35
|
-
|
|
35
|
+
public void reverseGeocode(double latitude, double longitude, PluginCall call) {
|
|
36
36
|
|
|
37
37
|
if (latitude == 0 || longitude == 0) {
|
|
38
38
|
call.reject("Expected two non-empty double arguments.");
|
|
@@ -58,8 +58,8 @@ public class NativeGeocoder {
|
|
|
58
58
|
|
|
59
59
|
// https://developer.android.com/reference/android/location/Address.html
|
|
60
60
|
JSONObject placemark = new JSONObject();
|
|
61
|
-
placemark.put("latitude", !String.valueOf(address.getLatitude()).isEmpty() ? address.getLatitude() :
|
|
62
|
-
placemark.put("longitude", !String.valueOf(address.getLongitude()).isEmpty() ? address.getLongitude() :
|
|
61
|
+
placemark.put("latitude", !String.valueOf(address.getLatitude()).isEmpty() ? address.getLatitude() : 0);
|
|
62
|
+
placemark.put("longitude", !String.valueOf(address.getLongitude()).isEmpty() ? address.getLongitude() : 0);
|
|
63
63
|
placemark.put("countryCode", address.getCountryCode() != null ? address.getCountryCode() : "");
|
|
64
64
|
placemark.put("countryName", address.getCountryName() != null ? address.getCountryName() : "");
|
|
65
65
|
placemark.put("postalCode", address.getPostalCode() != null ? address.getPostalCode() : "");
|
|
@@ -95,7 +95,7 @@ public class NativeGeocoder {
|
|
|
95
95
|
* @param addressString String
|
|
96
96
|
* @param call PluginCall
|
|
97
97
|
*/
|
|
98
|
-
|
|
98
|
+
public void forwardGeocode(String addressString, PluginCall call) {
|
|
99
99
|
if (addressString == null || addressString.length() == 0) {
|
|
100
100
|
call.reject("Expected a non-empty string argument.");
|
|
101
101
|
return;
|
|
@@ -126,8 +126,8 @@ public class NativeGeocoder {
|
|
|
126
126
|
if (!latitude.isEmpty() && !longitude.isEmpty()) {
|
|
127
127
|
// https://developer.android.com/reference/android/location/Address.html
|
|
128
128
|
JSObject placemark = new JSObject();
|
|
129
|
-
placemark.put("latitude",
|
|
130
|
-
placemark.put("longitude",
|
|
129
|
+
placemark.put("latitude", address.getLatitude());
|
|
130
|
+
placemark.put("longitude", address.getLongitude());
|
|
131
131
|
placemark.put("countryCode", address.getCountryCode() != null ? address.getCountryCode() : "");
|
|
132
132
|
placemark.put("countryName", address.getCountryName() != null ? address.getCountryName() : "");
|
|
133
133
|
placemark.put("postalCode", address.getPostalCode() != null ? address.getPostalCode() : "");
|
|
@@ -18,21 +18,21 @@ public class NativeGeocoderPlugin extends Plugin {
|
|
|
18
18
|
|
|
19
19
|
@PluginMethod
|
|
20
20
|
public void reverseGeocode(PluginCall call) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
Double latitude = call.getDouble("latitude");
|
|
22
|
+
Double longitude = call.getDouble("longitude");
|
|
23
|
+
if (latitude == null || longitude == null) {
|
|
24
|
+
call.reject("Missing latitude or longitude");
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
implementation.reverseGeocode(latitude, longitude, call);
|
|
27
28
|
}
|
|
28
29
|
@PluginMethod
|
|
29
30
|
public void forwardGeocode(PluginCall call) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
implementation.forwardGeocode(latitude, longitude, call);
|
|
31
|
+
String addressString = call.getString("addressString");
|
|
32
|
+
if (addressString == null) {
|
|
33
|
+
call.reject("Missing addressString");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
implementation.forwardGeocode(addressString, call);
|
|
37
37
|
}
|
|
38
38
|
}
|