@capgo/nativegeocoder 0.1.4 → 0.1.5

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.
@@ -1,4 +1,5 @@
1
1
  import Foundation
2
+ import Capacitor
2
3
  import CoreLocation
3
4
 
4
5
  struct NativeGeocoderResult: Encodable {
@@ -32,8 +33,7 @@ struct NativeGeocoderOptions: Decodable {
32
33
  typealias ForwardGeocodeCompletionHandler = ([NativeGeocoderResult]?, NativeGeocoderError?) -> Void
33
34
  private static let MAX_RESULTS_COUNT = 5
34
35
 
35
- // MARK: - REVERSE GEOCODE
36
- @objc(reverseGeocode:) func reverseGeocode(latitude: Double, longitude: Double, call: CAPPluginCall) {
36
+ func reverseGeocode(latitude: Double, longitude: Double, call: CAPPluginCall) {
37
37
  if (CLGeocoder().isGeocoding) {
38
38
  call.reject("Geocoder is busy. Please try again later.")
39
39
  return
@@ -41,9 +41,9 @@ struct NativeGeocoderOptions: Decodable {
41
41
 
42
42
  let location = CLLocation(latitude: latitude, longitude: longitude)
43
43
  var options = NativeGeocoderOptions(useLocale: true, defaultLocale: nil, maxResults: 1)
44
- options.useLocale = call.getBoolean("useLocale") ?? true
45
- options.defaultLocale = call.getString()
46
- options.maxResults = call.getNumber() ?? 1
44
+ options.useLocale = call.getBool("useLocale") ?? true
45
+ options.defaultLocale = call.getString("defaultLocale")
46
+ options.maxResults = call.getInt("maxResults") ?? 1
47
47
 
48
48
  reverseGeocodeLocationHandler(location, options: options, completionHandler: { [weak self] (resultObj, error) in
49
49
  if let error = error {
@@ -130,8 +130,7 @@ struct NativeGeocoderOptions: Decodable {
130
130
  }
131
131
 
132
132
 
133
- // MARK: - FORWARD GEOCODE
134
- @objc(forwardGeocode:)func forwardGeocode(address: String, call: CAPPluginCall) {
133
+ func forwardGeocode(address: String, call: CAPPluginCall) {
135
134
 
136
135
  if (CLGeocoder().isGeocoding) {
137
136
  call.reject("Geocoder is busy. Please try again later.")
@@ -139,9 +138,9 @@ struct NativeGeocoderOptions: Decodable {
139
138
  }
140
139
 
141
140
  var options = NativeGeocoderOptions(useLocale: true, defaultLocale: nil, maxResults: 1)
142
- options.useLocale = call.getBoolean("useLocale") ?? true
143
- options.defaultLocale = call.getString()
144
- options.maxResults = call.getNumber() ?? 1
141
+ options.useLocale = call.getBool("useLocale") ?? true
142
+ options.defaultLocale = call.getString("defaultLocale")
143
+ options.maxResults = call.getInt("maxResults") ?? 1
145
144
 
146
145
  forwardGeocodeHandler(address, options: options, completionHandler: { [weak self] (resultObj, error) in
147
146
  if let error = error {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/nativegeocoder",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
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",