@capgo/nativegeocoder 8.0.2 → 8.0.4
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.
|
@@ -9,7 +9,7 @@ import com.getcapacitor.annotation.CapacitorPlugin;
|
|
|
9
9
|
@CapacitorPlugin(name = "NativeGeocoder")
|
|
10
10
|
public class NativeGeocoderPlugin extends Plugin {
|
|
11
11
|
|
|
12
|
-
private final String pluginVersion = "8.0.
|
|
12
|
+
private final String pluginVersion = "8.0.4";
|
|
13
13
|
|
|
14
14
|
private NativeGeocoder implementation = new NativeGeocoder();
|
|
15
15
|
|
|
@@ -42,27 +42,18 @@ struct NativeGeocoderOptions: Decodable {
|
|
|
42
42
|
private func reverseGeocodeLocationHandler(_ location: CLLocation, options: NativeGeocoderOptions, completionHandler: @escaping ReverseGeocodeCompletionHandler) {
|
|
43
43
|
let geocoderOptions = getNativeGeocoderOptions(from: options)
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
45
|
+
var locale: Locale?
|
|
46
|
+
if let defaultLocaleString = geocoderOptions.defaultLocale {
|
|
47
|
+
locale = Locale.init(identifier: defaultLocaleString)
|
|
48
|
+
} else if geocoderOptions.useLocale == false {
|
|
49
|
+
locale = Locale.init(identifier: "en_US")
|
|
50
|
+
}
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
} else {
|
|
59
|
-
// fallback for < iOS 11
|
|
60
|
-
CLGeocoder().reverseGeocodeLocation(location, completionHandler: { [weak self] (placemarks, error) in
|
|
61
|
-
self?.createReverseGeocodeResult(placemarks, error, maxResults: geocoderOptions.maxResults, completionHandler: { (resultObj, error) in
|
|
62
|
-
completionHandler(resultObj, error)
|
|
63
|
-
})
|
|
52
|
+
CLGeocoder().reverseGeocodeLocation(location, preferredLocale: locale, completionHandler: { [weak self] (placemarks, error) in
|
|
53
|
+
self?.createReverseGeocodeResult(placemarks, error, maxResults: geocoderOptions.maxResults, completionHandler: { (resultObj, error) in
|
|
54
|
+
completionHandler(resultObj, error)
|
|
64
55
|
})
|
|
65
|
-
}
|
|
56
|
+
})
|
|
66
57
|
}
|
|
67
58
|
|
|
68
59
|
private func createReverseGeocodeResult(_ placemarks: [CLPlacemark]?, _ error: Error?, maxResults: Int, completionHandler: @escaping ReverseGeocodeCompletionHandler) {
|
|
@@ -129,27 +120,18 @@ struct NativeGeocoderOptions: Decodable {
|
|
|
129
120
|
func forwardGeocodeHandler(_ address: String, options: NativeGeocoderOptions, completionHandler: @escaping ForwardGeocodeCompletionHandler) {
|
|
130
121
|
let geocoderOptions = getNativeGeocoderOptions(from: options)
|
|
131
122
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
123
|
+
var locale: Locale?
|
|
124
|
+
if let defaultLocaleString = geocoderOptions.defaultLocale {
|
|
125
|
+
locale = Locale.init(identifier: defaultLocaleString)
|
|
126
|
+
} else if geocoderOptions.useLocale == false {
|
|
127
|
+
locale = Locale.init(identifier: "en_US")
|
|
128
|
+
}
|
|
139
129
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
})
|
|
144
|
-
})
|
|
145
|
-
} else {
|
|
146
|
-
// fallback for < iOS 11
|
|
147
|
-
CLGeocoder().geocodeAddressString(address, completionHandler: { [weak self] (placemarks, error) in
|
|
148
|
-
self?.createForwardGeocodeResult(placemarks, error, maxResults: geocoderOptions.maxResults, completionHandler: { (resultObj, error) in
|
|
149
|
-
completionHandler(resultObj, error)
|
|
150
|
-
})
|
|
130
|
+
CLGeocoder().geocodeAddressString(address, in: nil, preferredLocale: locale, completionHandler: { [weak self] (placemarks, error) in
|
|
131
|
+
self?.createForwardGeocodeResult(placemarks, error, maxResults: geocoderOptions.maxResults, completionHandler: { (resultObj, error) in
|
|
132
|
+
completionHandler(resultObj, error)
|
|
151
133
|
})
|
|
152
|
-
}
|
|
134
|
+
})
|
|
153
135
|
}
|
|
154
136
|
|
|
155
137
|
private func makePosition(_ placemark: CLPlacemark) -> JSObject {
|
|
@@ -7,7 +7,7 @@ import Capacitor
|
|
|
7
7
|
*/
|
|
8
8
|
@objc(NativeGeocoderPlugin)
|
|
9
9
|
public class NativeGeocoderPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
10
|
-
private let pluginVersion: String = "8.0.
|
|
10
|
+
private let pluginVersion: String = "8.0.4"
|
|
11
11
|
public let identifier = "NativeGeocoderPlugin"
|
|
12
12
|
public let jsName = "NativeGeocoder"
|
|
13
13
|
public let pluginMethods: [CAPPluginMethod] = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/nativegeocoder",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.4",
|
|
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",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
41
41
|
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
42
42
|
"eslint": "eslint .",
|
|
43
|
-
"prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
|
|
43
|
+
"prettier": "prettier-pretty-check \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
|
|
44
44
|
"swiftlint": "node-swiftlint",
|
|
45
45
|
"docgen": "docgen --api NativeGeocoderPlugin --output-readme README.md --output-json dist/docs.json",
|
|
46
46
|
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
|
|
@@ -66,7 +66,8 @@
|
|
|
66
66
|
"rimraf": "^6.1.0",
|
|
67
67
|
"rollup": "^4.53.2",
|
|
68
68
|
"swiftlint": "^2.0.0",
|
|
69
|
-
"typescript": "^5.9.3"
|
|
69
|
+
"typescript": "^5.9.3",
|
|
70
|
+
"prettier-pretty-check": "^0.2.0"
|
|
70
71
|
},
|
|
71
72
|
"peerDependencies": {
|
|
72
73
|
"@capacitor/core": ">=8.0.0"
|