@inoxialabs/react-native-nitro-location-geocoder 1.0.0 → 1.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/README.md +20 -20
- package/android/src/main/java/com/margelo/nitro/locationgeocoder/HybridLocationGeocoder.kt +71 -71
- package/ios/HybridLocationGeocoder.swift +78 -78
- package/nitrogen/generated/.gitattributes +1 -1
- package/nitrogen/generated/android/NitroLocationGeocoder+autolinking.cmake +81 -81
- package/nitrogen/generated/android/NitroLocationGeocoder+autolinking.gradle +27 -27
- package/nitrogen/generated/android/NitroLocationGeocoderOnLoad.cpp +54 -54
- package/nitrogen/generated/android/NitroLocationGeocoderOnLoad.hpp +34 -34
- package/nitrogen/generated/android/c++/JHybridLocationGeocoderSpec.cpp +69 -69
- package/nitrogen/generated/android/c++/JHybridLocationGeocoderSpec.hpp +63 -63
- package/nitrogen/generated/android/c++/JLocationGeocoderResult.hpp +77 -77
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/locationgeocoder/HybridLocationGeocoderSpec.kt +55 -55
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/locationgeocoder/LocationGeocoderResult.kt +76 -53
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/locationgeocoder/NitroLocationGeocoderOnLoad.kt +35 -35
- package/nitrogen/generated/ios/NitroLocationGeocoder+autolinking.rb +62 -60
- package/nitrogen/generated/ios/NitroLocationGeocoder-Swift-Cxx-Bridge.cpp +49 -49
- package/nitrogen/generated/ios/NitroLocationGeocoder-Swift-Cxx-Bridge.hpp +114 -114
- package/nitrogen/generated/ios/NitroLocationGeocoder-Swift-Cxx-Umbrella.hpp +48 -48
- package/nitrogen/generated/ios/NitroLocationGeocoderAutolinking.mm +33 -33
- package/nitrogen/generated/ios/NitroLocationGeocoderAutolinking.swift +26 -26
- package/nitrogen/generated/ios/c++/HybridLocationGeocoderSpecSwift.cpp +11 -11
- package/nitrogen/generated/ios/c++/HybridLocationGeocoderSpecSwift.hpp +85 -85
- package/nitrogen/generated/ios/swift/Func_void_LocationGeocoderResult.swift +46 -46
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -46
- package/nitrogen/generated/ios/swift/HybridLocationGeocoderSpec.swift +55 -55
- package/nitrogen/generated/ios/swift/HybridLocationGeocoderSpec_cxx.swift +145 -145
- package/nitrogen/generated/ios/swift/LocationGeocoderResult.swift +54 -54
- package/nitrogen/generated/shared/c++/HybridLocationGeocoderSpec.cpp +21 -21
- package/nitrogen/generated/shared/c++/HybridLocationGeocoderSpec.hpp +65 -65
- package/nitrogen/generated/shared/c++/LocationGeocoderResult.hpp +103 -103
- package/package.json +3 -3
- package/src/index.ts +47 -47
package/README.md
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- Reverse geocoding on iOS and Android.
|
|
8
|
-
- Locale-aware lookups using language tags
|
|
9
|
-
- Small, typed API with a normalized result shape.
|
|
10
|
-
- No backend dependency and no device location permission requirement.
|
|
11
|
-
- Stable generic errors for unavailable geocoders, empty results, invalid coordinates, timeouts, and native geocoder failures.
|
|
8
|
+
- Locale-aware lookups using language tags. For example: `en`, `es`, or `es-PE`.
|
|
9
|
+
- Small, typed API with a normalized result shape.
|
|
10
|
+
- No backend dependency and no device location permission requirement.
|
|
11
|
+
- Stable generic errors for unavailable geocoders, empty results, invalid coordinates, timeouts, and native geocoder failures.
|
|
12
12
|
|
|
13
13
|
## Supported platforms
|
|
14
14
|
|
|
@@ -29,7 +29,7 @@ Peer dependencies:
|
|
|
29
29
|
|
|
30
30
|
- `react`
|
|
31
31
|
- `react-native`
|
|
32
|
-
- `react-native-nitro-modules` `^0.35.0`
|
|
32
|
+
- `react-native-nitro-modules` `^0.35.0 || ^0.36.0`
|
|
33
33
|
|
|
34
34
|
On iOS, install pods after adding the package:
|
|
35
35
|
|
|
@@ -64,12 +64,12 @@ Returns `Promise<LocationGeocoderResult>`.
|
|
|
64
64
|
|
|
65
65
|
Parameters:
|
|
66
66
|
|
|
67
|
-
- `latitude`: required `number`
|
|
68
|
-
- `longitude`: required `number`
|
|
69
|
-
- `locale`: required `string`
|
|
70
|
-
|
|
71
|
-
`locale` accepts a language tag such as `en`, `es`, or `es-PE`. Passing `''` uses the platform default locale, but the argument itself is still required.
|
|
72
|
-
Latitude must be finite and between `-90` and `90`. Longitude must be finite and between `-180` and `180`.
|
|
67
|
+
- `latitude`: required `number`
|
|
68
|
+
- `longitude`: required `number`
|
|
69
|
+
- `locale`: required `string`
|
|
70
|
+
|
|
71
|
+
`locale` accepts a language tag such as `en`, `es`, or `es-PE`. Passing `''` uses the platform default locale, but the argument itself is still required.
|
|
72
|
+
Latitude must be finite and between `-90` and `90`. Longitude must be finite and between `-180` and `180`.
|
|
73
73
|
|
|
74
74
|
### `LocationGeocoderResult`
|
|
75
75
|
|
|
@@ -88,15 +88,15 @@ All fields are always present. When the platform geocoder cannot provide a field
|
|
|
88
88
|
|
|
89
89
|
## Platform behavior
|
|
90
90
|
|
|
91
|
-
- iOS uses `CLGeocoder`.
|
|
92
|
-
- Android uses `android.location.Geocoder`.
|
|
93
|
-
- Calls are independent. Starting one reverse-geocode request does not cancel another request.
|
|
94
|
-
- Requests time out after 10 seconds with `GEOCODER_TIMEOUT`.
|
|
95
|
-
- The module rejects with `INVALID_COORDINATES` when latitude or longitude is outside the valid coordinate range.
|
|
96
|
-
- The module rejects with `NO_RESULTS` when no address is found.
|
|
97
|
-
- Android rejects with `UNAVAILABLE` when the platform geocoder is not available.
|
|
98
|
-
- iOS wraps native geocoder failures as `GEOCODER_FAILED: <platform message>`.
|
|
99
|
-
- Android wraps native geocoder failures as `GEOCODER_FAILED` or `GEOCODER_FAILED: <platform message>`.
|
|
91
|
+
- iOS uses `CLGeocoder`.
|
|
92
|
+
- Android uses `android.location.Geocoder`.
|
|
93
|
+
- Calls are independent. Starting one reverse-geocode request does not cancel another request.
|
|
94
|
+
- Requests time out after 10 seconds with `GEOCODER_TIMEOUT`.
|
|
95
|
+
- The module rejects with `INVALID_COORDINATES` when latitude or longitude is outside the valid coordinate range.
|
|
96
|
+
- The module rejects with `NO_RESULTS` when no address is found.
|
|
97
|
+
- Android rejects with `UNAVAILABLE` when the platform geocoder is not available.
|
|
98
|
+
- iOS wraps native geocoder failures as `GEOCODER_FAILED: <platform message>`.
|
|
99
|
+
- Android wraps native geocoder failures as `GEOCODER_FAILED` or `GEOCODER_FAILED: <platform message>`.
|
|
100
100
|
|
|
101
101
|
## Notes
|
|
102
102
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
package com.margelo.nitro.locationgeocoder
|
|
2
2
|
|
|
3
|
-
import android.location.Address
|
|
4
|
-
import android.location.Geocoder
|
|
5
|
-
import android.os.Build
|
|
6
|
-
import androidx.annotation.RequiresApi
|
|
7
|
-
import com.facebook.proguard.annotations.DoNotStrip
|
|
8
|
-
import com.margelo.nitro.NitroModules
|
|
9
|
-
import com.margelo.nitro.core.Promise
|
|
10
|
-
import java.io.IOException
|
|
11
|
-
import java.util.Locale
|
|
12
|
-
import java.util.concurrent.CountDownLatch
|
|
13
|
-
import java.util.concurrent.TimeUnit
|
|
14
|
-
import java.util.concurrent.atomic.AtomicReference
|
|
15
|
-
|
|
3
|
+
import android.location.Address
|
|
4
|
+
import android.location.Geocoder
|
|
5
|
+
import android.os.Build
|
|
6
|
+
import androidx.annotation.RequiresApi
|
|
7
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
8
|
+
import com.margelo.nitro.NitroModules
|
|
9
|
+
import com.margelo.nitro.core.Promise
|
|
10
|
+
import java.io.IOException
|
|
11
|
+
import java.util.Locale
|
|
12
|
+
import java.util.concurrent.CountDownLatch
|
|
13
|
+
import java.util.concurrent.TimeUnit
|
|
14
|
+
import java.util.concurrent.atomic.AtomicReference
|
|
15
|
+
|
|
16
16
|
@DoNotStrip
|
|
17
17
|
class HybridLocationGeocoder : HybridLocationGeocoderSpec() {
|
|
18
18
|
|
|
@@ -26,55 +26,55 @@ class HybridLocationGeocoder : HybridLocationGeocoderSpec() {
|
|
|
26
26
|
return Locale.forLanguageTag(normalized)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
private fun createGeocoder(locale: String): Geocoder {
|
|
30
|
-
return Geocoder(context, getLocale(locale))
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
private fun isValidCoordinate(latitude: Double, longitude: Double): Boolean {
|
|
34
|
-
return latitude.isFinite() &&
|
|
35
|
-
longitude.isFinite() &&
|
|
36
|
-
latitude >= -90.0 &&
|
|
37
|
-
latitude <= 90.0 &&
|
|
38
|
-
longitude >= -180.0 &&
|
|
39
|
-
longitude <= 180.0
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
private fun geocoderFailed(message: String?): Exception {
|
|
43
|
-
val normalized = message?.trim()?.takeIf { it.isNotEmpty() }
|
|
44
|
-
return Exception(if (normalized == null) "GEOCODER_FAILED" else "GEOCODER_FAILED: $normalized")
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
override fun reverseGeocode(
|
|
48
|
-
latitude: Double,
|
|
49
|
-
longitude: Double,
|
|
50
|
-
locale: String
|
|
51
|
-
): Promise<LocationGeocoderResult> {
|
|
52
|
-
return Promise.async {
|
|
53
|
-
if (!isValidCoordinate(latitude, longitude)) {
|
|
54
|
-
throw Exception("INVALID_COORDINATES")
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (!Geocoder.isPresent()) {
|
|
58
|
-
throw Exception("UNAVAILABLE")
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
val address = try {
|
|
62
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
63
|
-
reverseGeocodeApi33(latitude, longitude, locale)
|
|
64
|
-
} else {
|
|
65
|
-
reverseGeocodeLegacy(latitude, longitude, locale)
|
|
66
|
-
}
|
|
67
|
-
} catch (error: IllegalArgumentException) {
|
|
68
|
-
throw Exception("INVALID_COORDINATES")
|
|
69
|
-
} catch (error: IOException) {
|
|
70
|
-
throw geocoderFailed(error.message)
|
|
71
|
-
} catch (error: InterruptedException) {
|
|
72
|
-
Thread.currentThread().interrupt()
|
|
73
|
-
throw geocoderFailed(error.message)
|
|
74
|
-
} ?: throw Exception("NO_RESULTS")
|
|
75
|
-
|
|
76
|
-
mapAddress(address)
|
|
77
|
-
}
|
|
29
|
+
private fun createGeocoder(locale: String): Geocoder {
|
|
30
|
+
return Geocoder(context, getLocale(locale))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
private fun isValidCoordinate(latitude: Double, longitude: Double): Boolean {
|
|
34
|
+
return latitude.isFinite() &&
|
|
35
|
+
longitude.isFinite() &&
|
|
36
|
+
latitude >= -90.0 &&
|
|
37
|
+
latitude <= 90.0 &&
|
|
38
|
+
longitude >= -180.0 &&
|
|
39
|
+
longitude <= 180.0
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private fun geocoderFailed(message: String?): Exception {
|
|
43
|
+
val normalized = message?.trim()?.takeIf { it.isNotEmpty() }
|
|
44
|
+
return Exception(if (normalized == null) "GEOCODER_FAILED" else "GEOCODER_FAILED: $normalized")
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
override fun reverseGeocode(
|
|
48
|
+
latitude: Double,
|
|
49
|
+
longitude: Double,
|
|
50
|
+
locale: String
|
|
51
|
+
): Promise<LocationGeocoderResult> {
|
|
52
|
+
return Promise.async {
|
|
53
|
+
if (!isValidCoordinate(latitude, longitude)) {
|
|
54
|
+
throw Exception("INVALID_COORDINATES")
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!Geocoder.isPresent()) {
|
|
58
|
+
throw Exception("UNAVAILABLE")
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
val address = try {
|
|
62
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
63
|
+
reverseGeocodeApi33(latitude, longitude, locale)
|
|
64
|
+
} else {
|
|
65
|
+
reverseGeocodeLegacy(latitude, longitude, locale)
|
|
66
|
+
}
|
|
67
|
+
} catch (error: IllegalArgumentException) {
|
|
68
|
+
throw Exception("INVALID_COORDINATES")
|
|
69
|
+
} catch (error: IOException) {
|
|
70
|
+
throw geocoderFailed(error.message)
|
|
71
|
+
} catch (error: InterruptedException) {
|
|
72
|
+
Thread.currentThread().interrupt()
|
|
73
|
+
throw geocoderFailed(error.message)
|
|
74
|
+
} ?: throw Exception("NO_RESULTS")
|
|
75
|
+
|
|
76
|
+
mapAddress(address)
|
|
77
|
+
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
|
|
@@ -88,15 +88,15 @@ class HybridLocationGeocoder : HybridLocationGeocoderSpec() {
|
|
|
88
88
|
override fun onGeocode(addresses: MutableList<Address>) {
|
|
89
89
|
resultRef.set(addresses.firstOrNull())
|
|
90
90
|
latch.countDown()
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
override fun onError(errorMessage: String?) {
|
|
94
|
-
errorRef.set(geocoderFailed(errorMessage))
|
|
95
|
-
latch.countDown()
|
|
96
|
-
}
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
val completed = latch.await(10, TimeUnit.SECONDS)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
override fun onError(errorMessage: String?) {
|
|
94
|
+
errorRef.set(geocoderFailed(errorMessage))
|
|
95
|
+
latch.countDown()
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
val completed = latch.await(10, TimeUnit.SECONDS)
|
|
100
100
|
if (!completed) {
|
|
101
101
|
throw Exception("GEOCODER_TIMEOUT")
|
|
102
102
|
}
|
|
@@ -2,91 +2,91 @@ import Foundation
|
|
|
2
2
|
import CoreLocation
|
|
3
3
|
import NitroModules
|
|
4
4
|
|
|
5
|
-
class HybridLocationGeocoder: HybridLocationGeocoderSpec {
|
|
6
|
-
|
|
7
|
-
private let timeoutSeconds: TimeInterval = 10
|
|
8
|
-
|
|
9
|
-
private func preferredLocale(_ locale: String) -> Locale? {
|
|
10
|
-
let normalized = locale.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
5
|
+
class HybridLocationGeocoder: HybridLocationGeocoderSpec {
|
|
6
|
+
|
|
7
|
+
private let timeoutSeconds: TimeInterval = 10
|
|
8
|
+
|
|
9
|
+
private func preferredLocale(_ locale: String) -> Locale? {
|
|
10
|
+
let normalized = locale.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
11
11
|
if normalized.isEmpty {
|
|
12
12
|
return nil
|
|
13
13
|
}
|
|
14
|
-
return Locale(identifier: normalized)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
private func isValidCoordinate(latitude: Double, longitude: Double) -> Bool {
|
|
18
|
-
latitude.isFinite &&
|
|
19
|
-
longitude.isFinite &&
|
|
20
|
-
latitude >= -90 &&
|
|
21
|
-
latitude <= 90 &&
|
|
22
|
-
longitude >= -180 &&
|
|
23
|
-
longitude <= 180
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
func reverseGeocode(latitude: Double, longitude: Double, locale: String) throws -> Promise<LocationGeocoderResult> {
|
|
27
|
-
let promise = Promise<LocationGeocoderResult>()
|
|
28
|
-
|
|
29
|
-
guard isValidCoordinate(latitude: latitude, longitude: longitude) else {
|
|
30
|
-
promise.reject(withError: RuntimeError.error(withMessage: "INVALID_COORDINATES"))
|
|
31
|
-
return promise
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
let geocoder = CLGeocoder()
|
|
35
|
-
var didComplete = false
|
|
36
|
-
var timeoutWorkItem: DispatchWorkItem?
|
|
37
|
-
|
|
38
|
-
func reject(_ message: String) {
|
|
39
|
-
if didComplete {
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
didComplete = true
|
|
43
|
-
timeoutWorkItem?.cancel()
|
|
44
|
-
promise.reject(withError: RuntimeError.error(withMessage: message))
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
func resolve(_ result: LocationGeocoderResult) {
|
|
48
|
-
if didComplete {
|
|
49
|
-
return
|
|
50
|
-
}
|
|
51
|
-
didComplete = true
|
|
52
|
-
timeoutWorkItem?.cancel()
|
|
53
|
-
promise.resolve(withResult: result)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
timeoutWorkItem = DispatchWorkItem {
|
|
57
|
-
reject("GEOCODER_TIMEOUT")
|
|
58
|
-
geocoder.cancelGeocode()
|
|
59
|
-
}
|
|
60
|
-
if let timeoutWorkItem = timeoutWorkItem {
|
|
61
|
-
DispatchQueue.main.asyncAfter(
|
|
62
|
-
deadline: .now() + .milliseconds(Int(timeoutSeconds * 1000)),
|
|
63
|
-
execute: timeoutWorkItem
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
let location = CLLocation(latitude: latitude, longitude: longitude)
|
|
68
|
-
geocoder.reverseGeocodeLocation(location, preferredLocale: preferredLocale(locale)) { placemarks, error in
|
|
69
|
-
if let error = error {
|
|
70
|
-
reject("GEOCODER_FAILED: \(error.localizedDescription)")
|
|
71
|
-
return
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
guard let placemark = placemarks?.first else {
|
|
75
|
-
reject("NO_RESULTS")
|
|
76
|
-
return
|
|
77
|
-
}
|
|
78
|
-
|
|
14
|
+
return Locale(identifier: normalized)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
private func isValidCoordinate(latitude: Double, longitude: Double) -> Bool {
|
|
18
|
+
latitude.isFinite &&
|
|
19
|
+
longitude.isFinite &&
|
|
20
|
+
latitude >= -90 &&
|
|
21
|
+
latitude <= 90 &&
|
|
22
|
+
longitude >= -180 &&
|
|
23
|
+
longitude <= 180
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
func reverseGeocode(latitude: Double, longitude: Double, locale: String) throws -> Promise<LocationGeocoderResult> {
|
|
27
|
+
let promise = Promise<LocationGeocoderResult>()
|
|
28
|
+
|
|
29
|
+
guard isValidCoordinate(latitude: latitude, longitude: longitude) else {
|
|
30
|
+
promise.reject(withError: RuntimeError.error(withMessage: "INVALID_COORDINATES"))
|
|
31
|
+
return promise
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let geocoder = CLGeocoder()
|
|
35
|
+
var didComplete = false
|
|
36
|
+
var timeoutWorkItem: DispatchWorkItem?
|
|
37
|
+
|
|
38
|
+
func reject(_ message: String) {
|
|
39
|
+
if didComplete {
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
didComplete = true
|
|
43
|
+
timeoutWorkItem?.cancel()
|
|
44
|
+
promise.reject(withError: RuntimeError.error(withMessage: message))
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
func resolve(_ result: LocationGeocoderResult) {
|
|
48
|
+
if didComplete {
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
didComplete = true
|
|
52
|
+
timeoutWorkItem?.cancel()
|
|
53
|
+
promise.resolve(withResult: result)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
timeoutWorkItem = DispatchWorkItem {
|
|
57
|
+
reject("GEOCODER_TIMEOUT")
|
|
58
|
+
geocoder.cancelGeocode()
|
|
59
|
+
}
|
|
60
|
+
if let timeoutWorkItem = timeoutWorkItem {
|
|
61
|
+
DispatchQueue.main.asyncAfter(
|
|
62
|
+
deadline: .now() + .milliseconds(Int(timeoutSeconds * 1000)),
|
|
63
|
+
execute: timeoutWorkItem
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let location = CLLocation(latitude: latitude, longitude: longitude)
|
|
68
|
+
geocoder.reverseGeocodeLocation(location, preferredLocale: preferredLocale(locale)) { placemarks, error in
|
|
69
|
+
if let error = error {
|
|
70
|
+
reject("GEOCODER_FAILED: \(error.localizedDescription)")
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
guard let placemark = placemarks?.first else {
|
|
75
|
+
reject("NO_RESULTS")
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
|
|
79
79
|
let result = LocationGeocoderResult(
|
|
80
80
|
countryCode: placemark.isoCountryCode ?? "",
|
|
81
81
|
country: placemark.country ?? "",
|
|
82
82
|
locality: placemark.locality ?? "",
|
|
83
83
|
administrativeArea: placemark.administrativeArea ?? "",
|
|
84
|
-
subAdministrativeArea: placemark.subAdministrativeArea ?? "",
|
|
85
|
-
subLocality: placemark.subLocality ?? ""
|
|
86
|
-
)
|
|
87
|
-
resolve(result)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return promise
|
|
84
|
+
subAdministrativeArea: placemark.subAdministrativeArea ?? "",
|
|
85
|
+
subLocality: placemark.subLocality ?? ""
|
|
86
|
+
)
|
|
87
|
+
resolve(result)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return promise
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
** linguist-generated=true
|
|
1
|
+
** linguist-generated=true
|
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
#
|
|
2
|
-
# NitroLocationGeocoder+autolinking.cmake
|
|
3
|
-
# This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
# https://github.com/mrousavy/nitro
|
|
5
|
-
# Copyright © Marc Rousavy @ Margelo
|
|
6
|
-
#
|
|
7
|
-
|
|
8
|
-
# This is a CMake file that adds all files generated by Nitrogen
|
|
9
|
-
# to the current CMake project.
|
|
10
|
-
#
|
|
11
|
-
# To use it, add this to your CMakeLists.txt:
|
|
12
|
-
# ```cmake
|
|
13
|
-
# include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/NitroLocationGeocoder+autolinking.cmake)
|
|
14
|
-
# ```
|
|
15
|
-
|
|
16
|
-
# Define a flag to check if we are building properly
|
|
17
|
-
add_definitions(-DBUILDING_NITROLOCATIONGEOCODER_WITH_GENERATED_CMAKE_PROJECT)
|
|
18
|
-
|
|
19
|
-
# Enable Raw Props parsing in react-native (for Nitro Views)
|
|
20
|
-
add_definitions(-DRN_SERIALIZABLE_STATE)
|
|
21
|
-
|
|
22
|
-
# Add all headers that were generated by Nitrogen
|
|
23
|
-
include_directories(
|
|
24
|
-
"../nitrogen/generated/shared/c++"
|
|
25
|
-
"../nitrogen/generated/android/c++"
|
|
26
|
-
"../nitrogen/generated/android/"
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
# Add all .cpp sources that were generated by Nitrogen
|
|
30
|
-
target_sources(
|
|
31
|
-
# CMake project name (Android C++ library name)
|
|
32
|
-
NitroLocationGeocoder PRIVATE
|
|
33
|
-
# Autolinking Setup
|
|
34
|
-
../nitrogen/generated/android/NitroLocationGeocoderOnLoad.cpp
|
|
35
|
-
# Shared Nitrogen C++ sources
|
|
36
|
-
../nitrogen/generated/shared/c++/HybridLocationGeocoderSpec.cpp
|
|
37
|
-
# Android-specific Nitrogen C++ sources
|
|
38
|
-
../nitrogen/generated/android/c++/JHybridLocationGeocoderSpec.cpp
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
|
|
42
|
-
# Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
|
|
43
|
-
target_compile_definitions(
|
|
44
|
-
NitroLocationGeocoder PRIVATE
|
|
45
|
-
-DFOLLY_NO_CONFIG=1
|
|
46
|
-
-DFOLLY_HAVE_CLOCK_GETTIME=1
|
|
47
|
-
-DFOLLY_USE_LIBCPP=1
|
|
48
|
-
-DFOLLY_CFG_NO_COROUTINES=1
|
|
49
|
-
-DFOLLY_MOBILE=1
|
|
50
|
-
-DFOLLY_HAVE_RECVMMSG=1
|
|
51
|
-
-DFOLLY_HAVE_PTHREAD=1
|
|
52
|
-
# Once we target android-23 above, we can comment
|
|
53
|
-
# the following line. NDK uses GNU style stderror_r() after API 23.
|
|
54
|
-
-DFOLLY_HAVE_XSI_STRERROR_R=1
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
# Add all libraries required by the generated specs
|
|
58
|
-
find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
|
|
59
|
-
find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
|
|
60
|
-
find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
|
|
61
|
-
|
|
62
|
-
# Link all libraries together
|
|
63
|
-
target_link_libraries(
|
|
64
|
-
NitroLocationGeocoder
|
|
65
|
-
fbjni::fbjni # <-- Facebook C++ JNI helpers
|
|
66
|
-
ReactAndroid::jsi # <-- RN: JSI
|
|
67
|
-
react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
# Link react-native (different prefab between RN 0.75 and RN 0.76)
|
|
71
|
-
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
|
72
|
-
target_link_libraries(
|
|
73
|
-
NitroLocationGeocoder
|
|
74
|
-
ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
|
|
75
|
-
)
|
|
76
|
-
else()
|
|
77
|
-
target_link_libraries(
|
|
78
|
-
NitroLocationGeocoder
|
|
79
|
-
ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
|
|
80
|
-
)
|
|
81
|
-
endif()
|
|
1
|
+
#
|
|
2
|
+
# NitroLocationGeocoder+autolinking.cmake
|
|
3
|
+
# This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
# https://github.com/mrousavy/nitro
|
|
5
|
+
# Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
# This is a CMake file that adds all files generated by Nitrogen
|
|
9
|
+
# to the current CMake project.
|
|
10
|
+
#
|
|
11
|
+
# To use it, add this to your CMakeLists.txt:
|
|
12
|
+
# ```cmake
|
|
13
|
+
# include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/NitroLocationGeocoder+autolinking.cmake)
|
|
14
|
+
# ```
|
|
15
|
+
|
|
16
|
+
# Define a flag to check if we are building properly
|
|
17
|
+
add_definitions(-DBUILDING_NITROLOCATIONGEOCODER_WITH_GENERATED_CMAKE_PROJECT)
|
|
18
|
+
|
|
19
|
+
# Enable Raw Props parsing in react-native (for Nitro Views)
|
|
20
|
+
add_definitions(-DRN_SERIALIZABLE_STATE)
|
|
21
|
+
|
|
22
|
+
# Add all headers that were generated by Nitrogen
|
|
23
|
+
include_directories(
|
|
24
|
+
"../nitrogen/generated/shared/c++"
|
|
25
|
+
"../nitrogen/generated/android/c++"
|
|
26
|
+
"../nitrogen/generated/android/"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# Add all .cpp sources that were generated by Nitrogen
|
|
30
|
+
target_sources(
|
|
31
|
+
# CMake project name (Android C++ library name)
|
|
32
|
+
NitroLocationGeocoder PRIVATE
|
|
33
|
+
# Autolinking Setup
|
|
34
|
+
../nitrogen/generated/android/NitroLocationGeocoderOnLoad.cpp
|
|
35
|
+
# Shared Nitrogen C++ sources
|
|
36
|
+
../nitrogen/generated/shared/c++/HybridLocationGeocoderSpec.cpp
|
|
37
|
+
# Android-specific Nitrogen C++ sources
|
|
38
|
+
../nitrogen/generated/android/c++/JHybridLocationGeocoderSpec.cpp
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
|
|
42
|
+
# Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
|
|
43
|
+
target_compile_definitions(
|
|
44
|
+
NitroLocationGeocoder PRIVATE
|
|
45
|
+
-DFOLLY_NO_CONFIG=1
|
|
46
|
+
-DFOLLY_HAVE_CLOCK_GETTIME=1
|
|
47
|
+
-DFOLLY_USE_LIBCPP=1
|
|
48
|
+
-DFOLLY_CFG_NO_COROUTINES=1
|
|
49
|
+
-DFOLLY_MOBILE=1
|
|
50
|
+
-DFOLLY_HAVE_RECVMMSG=1
|
|
51
|
+
-DFOLLY_HAVE_PTHREAD=1
|
|
52
|
+
# Once we target android-23 above, we can comment
|
|
53
|
+
# the following line. NDK uses GNU style stderror_r() after API 23.
|
|
54
|
+
-DFOLLY_HAVE_XSI_STRERROR_R=1
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
# Add all libraries required by the generated specs
|
|
58
|
+
find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
|
|
59
|
+
find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
|
|
60
|
+
find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
|
|
61
|
+
|
|
62
|
+
# Link all libraries together
|
|
63
|
+
target_link_libraries(
|
|
64
|
+
NitroLocationGeocoder
|
|
65
|
+
fbjni::fbjni # <-- Facebook C++ JNI helpers
|
|
66
|
+
ReactAndroid::jsi # <-- RN: JSI
|
|
67
|
+
react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
# Link react-native (different prefab between RN 0.75 and RN 0.76)
|
|
71
|
+
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
|
72
|
+
target_link_libraries(
|
|
73
|
+
NitroLocationGeocoder
|
|
74
|
+
ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
|
|
75
|
+
)
|
|
76
|
+
else()
|
|
77
|
+
target_link_libraries(
|
|
78
|
+
NitroLocationGeocoder
|
|
79
|
+
ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
|
|
80
|
+
)
|
|
81
|
+
endif()
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// NitroLocationGeocoder+autolinking.gradle
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
-
///
|
|
7
|
-
|
|
8
|
-
/// This is a Gradle file that adds all files generated by Nitrogen
|
|
9
|
-
/// to the current Gradle project.
|
|
10
|
-
///
|
|
11
|
-
/// To use it, add this to your build.gradle:
|
|
12
|
-
/// ```gradle
|
|
13
|
-
/// apply from: '../nitrogen/generated/android/NitroLocationGeocoder+autolinking.gradle'
|
|
14
|
-
/// ```
|
|
15
|
-
|
|
16
|
-
logger.warn("[NitroModules] 🔥 NitroLocationGeocoder is boosted by nitro!")
|
|
17
|
-
|
|
18
|
-
android {
|
|
19
|
-
sourceSets {
|
|
20
|
-
main {
|
|
21
|
-
java.srcDirs += [
|
|
22
|
-
// Nitrogen files
|
|
23
|
-
"${project.projectDir}/../nitrogen/generated/android/kotlin"
|
|
24
|
-
]
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
1
|
+
///
|
|
2
|
+
/// NitroLocationGeocoder+autolinking.gradle
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
/// This is a Gradle file that adds all files generated by Nitrogen
|
|
9
|
+
/// to the current Gradle project.
|
|
10
|
+
///
|
|
11
|
+
/// To use it, add this to your build.gradle:
|
|
12
|
+
/// ```gradle
|
|
13
|
+
/// apply from: '../nitrogen/generated/android/NitroLocationGeocoder+autolinking.gradle'
|
|
14
|
+
/// ```
|
|
15
|
+
|
|
16
|
+
logger.warn("[NitroModules] 🔥 NitroLocationGeocoder is boosted by nitro!")
|
|
17
|
+
|
|
18
|
+
android {
|
|
19
|
+
sourceSets {
|
|
20
|
+
main {
|
|
21
|
+
java.srcDirs += [
|
|
22
|
+
// Nitrogen files
|
|
23
|
+
"${project.projectDir}/../nitrogen/generated/android/kotlin"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|