expo-location 58.0.21 → 58.0.22
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/CHANGELOG.md +7 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/location/next/LocationModuleNext.kt +29 -0
- package/android/src/main/java/expo/modules/location/next/LocationRecords.kt +6 -2
- package/android/src/main/java/expo/modules/location/next/geocoding/Geocoding.kt +117 -0
- package/android/src/main/java/expo/modules/location/next/geocoding/GeocodingExceptions.kt +27 -0
- package/android/src/main/java/expo/modules/location/next/geocoding/GeocodingRecords.kt +24 -0
- package/build/next/Location.d.ts +1 -1
- package/build/next/Location.js +1 -1
- package/build/next/Location.js.map +1 -1
- package/build/next/index.d.ts +1 -1
- package/build/next/index.js.map +1 -1
- package/build/next/js/geocoding.d.ts +38 -0
- package/build/next/js/geocoding.js +49 -0
- package/build/next/js/geocoding.js.map +1 -0
- package/build/next/js/index.d.ts +1 -0
- package/build/next/js/index.js +1 -0
- package/build/next/js/index.js.map +1 -1
- package/build/next/native/types/NativeLocationModuleNextClass.types.d.ts +3 -1
- package/build/next/types/Geocoding.types.d.ts +74 -0
- package/build/next/types/Geocoding.types.js +7 -0
- package/build/next/types/Geocoding.types.js.map +1 -0
- package/build/next/types/index.d.ts +1 -0
- package/build/next/types/index.js +1 -0
- package/build/next/types/index.js.map +1 -1
- package/ios/next/Geocoding/Address.swift +11 -0
- package/ios/next/Geocoding/AddressNormalization.swift +8 -0
- package/ios/next/Geocoding/CompatibilityGeocoder.swift +73 -0
- package/ios/next/Geocoding/GeocodeOptions.swift +6 -0
- package/ios/next/Geocoding/GeocoderNext.swift +4 -0
- package/ios/next/Geocoding/MapKitGeocoder.swift +70 -0
- package/ios/next/Geocoding/ReverseGeocodeOptions.swift +6 -0
- package/ios/next/Geocoding/String+toLocale.swift +12 -0
- package/ios/next/LocationModuleNext.swift +15 -0
- package/ios/next/LocationNextExceptions.swift +19 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.21/expo.modules.location-58.0.21-sources.jar → 58.0.22/expo.modules.location-58.0.22-sources.jar} +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.22/expo.modules.location-58.0.22-sources.jar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.22/expo.modules.location-58.0.22-sources.jar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.22/expo.modules.location-58.0.22-sources.jar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.22/expo.modules.location-58.0.22-sources.jar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.22/expo.modules.location-58.0.22.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.22/expo.modules.location-58.0.22.aar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.22/expo.modules.location-58.0.22.aar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.22/expo.modules.location-58.0.22.aar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.22/expo.modules.location-58.0.22.aar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.21/expo.modules.location-58.0.21.module → 58.0.22/expo.modules.location-58.0.22.module} +22 -22
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.22/expo.modules.location-58.0.22.module.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.22/expo.modules.location-58.0.22.module.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.22/expo.modules.location-58.0.22.module.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.22/expo.modules.location-58.0.22.module.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.21/expo.modules.location-58.0.21.pom → 58.0.22/expo.modules.location-58.0.22.pom} +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.22/expo.modules.location-58.0.22.pom.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.22/expo.modules.location-58.0.22.pom.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.22/expo.modules.location-58.0.22.pom.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.22/expo.modules.location-58.0.22.pom.sha512 +1 -0
- package/package.json +2 -2
- package/src/next/Location.ts +2 -0
- package/src/next/index.ts +3 -0
- package/src/next/js/geocoding.ts +56 -0
- package/src/next/js/index.ts +1 -0
- package/src/next/native/types/NativeLocationModuleNextClass.types.ts +6 -0
- package/src/next/types/Geocoding.types.ts +77 -0
- package/src/next/types/index.ts +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21-sources.jar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21-sources.jar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21-sources.jar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21-sources.jar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.aar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.aar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.aar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.aar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.module.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.module.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.module.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.module.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.pom.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.pom.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.pom.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.pom.sha512 +0 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
import MapKit
|
|
3
|
+
|
|
4
|
+
@available(iOS 26.0, *)
|
|
5
|
+
final class MapKitGeocoder: GeocoderNext {
|
|
6
|
+
var forwardMapItems: (_ address: String, _ locale: Locale?) async throws -> [MKMapItem] = { address, locale in
|
|
7
|
+
guard let request = MKGeocodingRequest(addressString: address) else {
|
|
8
|
+
return []
|
|
9
|
+
}
|
|
10
|
+
request.preferredLocale = locale
|
|
11
|
+
return try await request.mapItems
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
var reverseMapItems: (_ location: CLLocation, _ locale: Locale?) async throws -> [MKMapItem] = { location, locale in
|
|
15
|
+
guard let request = MKReverseGeocodingRequest(location: location) else {
|
|
16
|
+
return []
|
|
17
|
+
}
|
|
18
|
+
request.preferredLocale = locale
|
|
19
|
+
return try await request.mapItems
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
func geocode(_ address: String, options: GeocodeOptions) async throws -> [Address] {
|
|
23
|
+
do {
|
|
24
|
+
return try await forwardMapItems(address, options.locale?.toLocale()).map { $0.toAddress() }
|
|
25
|
+
} catch {
|
|
26
|
+
return try handleGeocodingError(error)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
func reverseGeocode(_ coordinates: Coordinates, options: ReverseGeocodeOptions) async throws -> [Address] {
|
|
31
|
+
guard CLLocationCoordinate2DIsValid(
|
|
32
|
+
CLLocationCoordinate2D(latitude: coordinates.latitude, longitude: coordinates.longitude)
|
|
33
|
+
) else {
|
|
34
|
+
throw InvalidCoordinatesException()
|
|
35
|
+
}
|
|
36
|
+
let location = CLLocation(latitude: coordinates.latitude, longitude: coordinates.longitude)
|
|
37
|
+
do {
|
|
38
|
+
return try await reverseMapItems(location, options.locale?.toLocale()).map { $0.toAddress() }
|
|
39
|
+
} catch {
|
|
40
|
+
return try handleGeocodingError(error)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private func handleGeocodingError(_ error: Error) throws -> [Address] {
|
|
45
|
+
switch error {
|
|
46
|
+
case MKError.placemarkNotFound:
|
|
47
|
+
return []
|
|
48
|
+
case MKError.loadingThrottled, MKError.serverFailure:
|
|
49
|
+
throw GeocodingUnavailableException().causedBy(error)
|
|
50
|
+
default:
|
|
51
|
+
throw GeocodingFailedException().causedBy(error)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@available(iOS 26.0, *)
|
|
57
|
+
private extension MKMapItem {
|
|
58
|
+
func toAddress() -> Address {
|
|
59
|
+
Address(
|
|
60
|
+
coordinates: Coordinates(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude),
|
|
61
|
+
name: normalizeAddressString(name),
|
|
62
|
+
formattedAddress: normalizeAddressString(
|
|
63
|
+
addressRepresentations?.fullAddress(includingRegion: true, singleLine: true)
|
|
64
|
+
),
|
|
65
|
+
city: normalizeAddressString(addressRepresentations?.cityName),
|
|
66
|
+
country: normalizeAddressString(addressRepresentations?.regionName),
|
|
67
|
+
isoCountryCode: normalizeAddressString(addressRepresentations?.region?.identifier)
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
|
|
3
|
+
extension String {
|
|
4
|
+
func toLocale() -> Locale {
|
|
5
|
+
let locale = Locale(identifier: self)
|
|
6
|
+
let isISOLanguage = locale.language.languageCode?.isISOLanguage ?? false
|
|
7
|
+
if !isISOLanguage {
|
|
8
|
+
log.warn("[expo-location] The locale '\(self)' has no recognized language code, so geocoding results use the device language. Pass a BCP 47 tag such as 'en-US'.")
|
|
9
|
+
}
|
|
10
|
+
return locale
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -5,6 +5,13 @@ public final class LocationModuleNext: Module {
|
|
|
5
5
|
private lazy var permissions = LocationPermissionsDelegate(appContext: appContext)
|
|
6
6
|
private lazy var accessGuard = LocationAccessGuard(appContext: appContext)
|
|
7
7
|
|
|
8
|
+
private lazy var geocoder: any GeocoderNext = {
|
|
9
|
+
if #available(iOS 26.0, *) {
|
|
10
|
+
return MapKitGeocoder()
|
|
11
|
+
}
|
|
12
|
+
return CompatibilityGeocoder()
|
|
13
|
+
}()
|
|
14
|
+
|
|
8
15
|
public func definition() -> ModuleDefinition {
|
|
9
16
|
Name("LocationModuleNext")
|
|
10
17
|
|
|
@@ -42,6 +49,14 @@ public final class LocationModuleNext: Module {
|
|
|
42
49
|
return location?.toPosition()
|
|
43
50
|
}
|
|
44
51
|
|
|
52
|
+
AsyncFunction("geocode") { (address: String, options: GeocodeOptions?) -> [Address] in
|
|
53
|
+
try await geocoder.geocode(address, options: options ?? GeocodeOptions())
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
AsyncFunction("reverseGeocode") { (coordinates: Coordinates, options: ReverseGeocodeOptions?) -> [Address] in
|
|
57
|
+
try await geocoder.reverseGeocode(coordinates, options: options ?? ReverseGeocodeOptions())
|
|
58
|
+
}
|
|
59
|
+
|
|
45
60
|
Function("watchPosition") { (profile: Profile?) -> PositionWatcher in
|
|
46
61
|
guard CLLocationManager.locationServicesEnabled() else {
|
|
47
62
|
throw LocationServicesDisabledGlobally()
|
|
@@ -108,3 +108,22 @@ final class MissingPlistKeyException: GenericException<String>, @unchecked Senda
|
|
|
108
108
|
"granted. Add the key via the expo-location config plugin or by hand, then rebuild the app"
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
+
|
|
112
|
+
final class InvalidCoordinatesException: Exception, @unchecked Sendable {
|
|
113
|
+
override var reason: String {
|
|
114
|
+
"Cannot reverse geocode invalid coordinates. Provide a finite latitude between -90 and 90 " +
|
|
115
|
+
"and a finite longitude between -180 and 180, in degrees"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
final class GeocodingUnavailableException: Exception, @unchecked Sendable {
|
|
120
|
+
override var reason: String {
|
|
121
|
+
"Geocoding is unavailable."
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
final class GeocodingFailedException: Exception, @unchecked Sendable {
|
|
126
|
+
override var reason: String {
|
|
127
|
+
"Geocoding failed."
|
|
128
|
+
}
|
|
129
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
51236a55712f41024ffe929c741fa70f
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
d5abb68e7265f969567c4215286ab5f74eff9ec5
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1007222ddfb5a58a10abacd322f513c4848e75b6aa5e11a8978d511f7631c8fe
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
823897a67cf374cde60d157ddbb46efbd33ff74fac61c2584d1b5490e923155654ed9503894e89991fad241c717de36e7a6c88f05610d236f81bb29a01dab727
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
c11c50da2395ffe54a862e51ca404d18
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2c5398202a08f56f4711ad3a01b248446df292fc
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
b915457d3a7c2965d8731bca1c940c8685cb1ff1cfa83147fd4d4930f9c9e5c1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
4c87739df3839875b9db9b9115203784f146839304024bfb8f78379ec067566a17f27d265ba84466338f1e8b3b6c88d0b9f385847e0c919d9d4a234df14fbee2
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"component": {
|
|
4
4
|
"group": "host.exp.exponent",
|
|
5
5
|
"module": "expo.modules.location",
|
|
6
|
-
"version": "58.0.
|
|
6
|
+
"version": "58.0.22",
|
|
7
7
|
"attributes": {
|
|
8
8
|
"org.gradle.status": "release"
|
|
9
9
|
}
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
],
|
|
34
34
|
"files": [
|
|
35
35
|
{
|
|
36
|
-
"name": "expo.modules.location-58.0.
|
|
37
|
-
"url": "expo.modules.location-58.0.
|
|
38
|
-
"size":
|
|
39
|
-
"sha512": "
|
|
40
|
-
"sha256": "
|
|
41
|
-
"sha1": "
|
|
42
|
-
"md5": "
|
|
36
|
+
"name": "expo.modules.location-58.0.22.aar",
|
|
37
|
+
"url": "expo.modules.location-58.0.22.aar",
|
|
38
|
+
"size": 613645,
|
|
39
|
+
"sha512": "4c87739df3839875b9db9b9115203784f146839304024bfb8f78379ec067566a17f27d265ba84466338f1e8b3b6c88d0b9f385847e0c919d9d4a234df14fbee2",
|
|
40
|
+
"sha256": "b915457d3a7c2965d8731bca1c940c8685cb1ff1cfa83147fd4d4930f9c9e5c1",
|
|
41
|
+
"sha1": "2c5398202a08f56f4711ad3a01b248446df292fc",
|
|
42
|
+
"md5": "c11c50da2395ffe54a862e51ca404d18"
|
|
43
43
|
}
|
|
44
44
|
]
|
|
45
45
|
},
|
|
@@ -90,13 +90,13 @@
|
|
|
90
90
|
],
|
|
91
91
|
"files": [
|
|
92
92
|
{
|
|
93
|
-
"name": "expo.modules.location-58.0.
|
|
94
|
-
"url": "expo.modules.location-58.0.
|
|
95
|
-
"size":
|
|
96
|
-
"sha512": "
|
|
97
|
-
"sha256": "
|
|
98
|
-
"sha1": "
|
|
99
|
-
"md5": "
|
|
93
|
+
"name": "expo.modules.location-58.0.22.aar",
|
|
94
|
+
"url": "expo.modules.location-58.0.22.aar",
|
|
95
|
+
"size": 613645,
|
|
96
|
+
"sha512": "4c87739df3839875b9db9b9115203784f146839304024bfb8f78379ec067566a17f27d265ba84466338f1e8b3b6c88d0b9f385847e0c919d9d4a234df14fbee2",
|
|
97
|
+
"sha256": "b915457d3a7c2965d8731bca1c940c8685cb1ff1cfa83147fd4d4930f9c9e5c1",
|
|
98
|
+
"sha1": "2c5398202a08f56f4711ad3a01b248446df292fc",
|
|
99
|
+
"md5": "c11c50da2395ffe54a862e51ca404d18"
|
|
100
100
|
}
|
|
101
101
|
]
|
|
102
102
|
},
|
|
@@ -110,13 +110,13 @@
|
|
|
110
110
|
},
|
|
111
111
|
"files": [
|
|
112
112
|
{
|
|
113
|
-
"name": "expo.modules.location-58.0.
|
|
114
|
-
"url": "expo.modules.location-58.0.
|
|
115
|
-
"size":
|
|
116
|
-
"sha512": "
|
|
117
|
-
"sha256": "
|
|
118
|
-
"sha1": "
|
|
119
|
-
"md5": "
|
|
113
|
+
"name": "expo.modules.location-58.0.22-sources.jar",
|
|
114
|
+
"url": "expo.modules.location-58.0.22-sources.jar",
|
|
115
|
+
"size": 56085,
|
|
116
|
+
"sha512": "823897a67cf374cde60d157ddbb46efbd33ff74fac61c2584d1b5490e923155654ed9503894e89991fad241c717de36e7a6c88f05610d236f81bb29a01dab727",
|
|
117
|
+
"sha256": "1007222ddfb5a58a10abacd322f513c4848e75b6aa5e11a8978d511f7631c8fe",
|
|
118
|
+
"sha1": "d5abb68e7265f969567c4215286ab5f74eff9ec5",
|
|
119
|
+
"md5": "51236a55712f41024ffe929c741fa70f"
|
|
120
120
|
}
|
|
121
121
|
]
|
|
122
122
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
5bd9f798302226aa71bcba879591fe7c
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
e473f57542caad600bb738bf61f7932e2e1fefcc
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
7eff2a730f37f33833fc37735364414a3ffb2a89ee28669c039bacb3714892e1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
f0e5d4d5c1f7a2de3bc04f411971725c1cb0b61a35c1ebafa1dd09d811c1193347aae77ef64f794158111c287d14aa078e6a1c7b51bae797602e1e06de094569
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<modelVersion>4.0.0</modelVersion>
|
|
10
10
|
<groupId>host.exp.exponent</groupId>
|
|
11
11
|
<artifactId>expo.modules.location</artifactId>
|
|
12
|
-
<version>58.0.
|
|
12
|
+
<version>58.0.22</version>
|
|
13
13
|
<packaging>aar</packaging>
|
|
14
14
|
<name>expo.modules.location</name>
|
|
15
15
|
<url>https://github.com/expo/expo</url>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0d6e3ea8118fe8eb9968d98c628c05f2
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
780c3d4de8115e35230f01740b475605107c3f6a
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
b635797432a9dfd517cd6dac2d542c8363b22544004c42bd299fa639223a1d33
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3f6769ccb3c9d1113fee85a4a304b0898c4d6937f793956511c743dbf5cc136aa0a5cad69bcb76c3e28a7138453605b488f603491200c216a67082082b6f4d73
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-location",
|
|
3
|
-
"version": "58.0.
|
|
3
|
+
"version": "58.0.22",
|
|
4
4
|
"description": "Allows reading geolocation information from the device. Your app can poll for the current location or subscribe to location update events.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compass",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@types/jest": "^30.0.0",
|
|
57
57
|
"@types/node": "^22.14.0",
|
|
58
58
|
"@types/react": "~19.3.0",
|
|
59
|
-
"expo": "58.0.
|
|
59
|
+
"expo": "58.0.25",
|
|
60
60
|
"expo-task-manager": "~58.0.14"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
package/src/next/Location.ts
CHANGED
package/src/next/index.ts
CHANGED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Platform, UnavailabilityError } from 'expo';
|
|
2
|
+
|
|
3
|
+
import { NativeLocationModuleNext } from '../native';
|
|
4
|
+
import type { Address, Coordinates, GeocodeOptions, ReverseGeocodeOptions } from '../types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Finds the places that match an address string. Requires a network connection.
|
|
8
|
+
*
|
|
9
|
+
* @param address The text to look up, for example, `1 Infinite Loop, Cupertino`.
|
|
10
|
+
* @param options The language of the result.
|
|
11
|
+
* @return A promise that resolves to the matching addresses, or to an empty array when there are none.
|
|
12
|
+
* @throws When the device has no geocoding backend, geocoding is unavailable, or the request fails.
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const [match] = await Location.geocode('1 Infinite Loop, Cupertino');
|
|
16
|
+
* if (match) {
|
|
17
|
+
* console.log(match.coordinates.latitude, match.coordinates.longitude);
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
* @platform android
|
|
21
|
+
* @platform ios
|
|
22
|
+
*/
|
|
23
|
+
export async function geocode(address: string, options?: GeocodeOptions): Promise<Address[]> {
|
|
24
|
+
if (Platform.OS !== 'android' && Platform.OS !== 'ios') {
|
|
25
|
+
throw new UnavailabilityError('expo-location', 'geocode');
|
|
26
|
+
}
|
|
27
|
+
return NativeLocationModuleNext.geocode(address, options);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Finds the addresses at the given coordinates. Requires a network connection.
|
|
32
|
+
*
|
|
33
|
+
* @param coordinates The point to look up.
|
|
34
|
+
* @param options The language of the result.
|
|
35
|
+
* @return A promise that resolves to the addresses at the point, or to an empty array when there are none.
|
|
36
|
+
* @throws When the coordinates are invalid, the device has no geocoding backend, geocoding is unavailable, or the request fails.
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const position = await Location.getPosition();
|
|
40
|
+
* if (position) {
|
|
41
|
+
* const [address] = await Location.reverseGeocode(position.coordinates);
|
|
42
|
+
* console.log(address?.formattedAddress);
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
* @platform android
|
|
46
|
+
* @platform ios
|
|
47
|
+
*/
|
|
48
|
+
export async function reverseGeocode(
|
|
49
|
+
coordinates: Coordinates,
|
|
50
|
+
options?: ReverseGeocodeOptions
|
|
51
|
+
): Promise<Address[]> {
|
|
52
|
+
if (Platform.OS !== 'android' && Platform.OS !== 'ios') {
|
|
53
|
+
throw new UnavailabilityError('expo-location', 'reverseGeocode');
|
|
54
|
+
}
|
|
55
|
+
return NativeLocationModuleNext.reverseGeocode(coordinates, options);
|
|
56
|
+
}
|
package/src/next/js/index.ts
CHANGED
|
@@ -2,12 +2,16 @@ import { NativeModule } from 'expo';
|
|
|
2
2
|
import type { PermissionResponse, SharedRef } from 'expo';
|
|
3
3
|
|
|
4
4
|
import type {
|
|
5
|
+
Address,
|
|
6
|
+
Coordinates,
|
|
7
|
+
GeocodeOptions,
|
|
5
8
|
GetPositionOptions,
|
|
6
9
|
LocationPermissionResponse,
|
|
7
10
|
LocationProfile,
|
|
8
11
|
LocationProviderRefType,
|
|
9
12
|
Position,
|
|
10
13
|
RequestPermissionsOptions,
|
|
14
|
+
ReverseGeocodeOptions,
|
|
11
15
|
} from '../../types';
|
|
12
16
|
import type { NativeBackgroundSessionClass } from './NativeBackgroundSessionClass.types';
|
|
13
17
|
import type { NativeLocationProviderClass } from './NativeLocationProviderClass.types';
|
|
@@ -31,6 +35,8 @@ export declare class NativeLocationModuleNextClass extends NativeModule {
|
|
|
31
35
|
enableLocationServices(): Promise<boolean>;
|
|
32
36
|
getPosition(options?: GetPositionOptions): Promise<Position | null>;
|
|
33
37
|
watchPosition(profile?: LocationProfile): NativePositionWatchHandleClass;
|
|
38
|
+
geocode(address: string, options?: GeocodeOptions): Promise<Address[]>;
|
|
39
|
+
reverseGeocode(coordinates: Coordinates, options?: ReverseGeocodeOptions): Promise<Address[]>;
|
|
34
40
|
LocationProvider: typeof NativeLocationProviderClass;
|
|
35
41
|
PositionWatchHandle: typeof NativePositionWatchHandleClass;
|
|
36
42
|
LocationUpdatesHandle: typeof NativeLocationUpdatesHandleClass;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Coordinates } from './Position.types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* An address paired with the coordinates it stands for. Fields the platform does not know for a
|
|
5
|
+
* given place are `null`.
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* {
|
|
9
|
+
* coordinates: { latitude: 37.3317, longitude: -122.0301 },
|
|
10
|
+
* name: '1 Infinite Loop',
|
|
11
|
+
* formattedAddress: '1 Infinite Loop, Cupertino, CA 95014, United States',
|
|
12
|
+
* city: 'Cupertino',
|
|
13
|
+
* country: 'United States',
|
|
14
|
+
* isoCountryCode: 'US',
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
* @platform android
|
|
18
|
+
* @platform ios
|
|
19
|
+
*/
|
|
20
|
+
export type Address = {
|
|
21
|
+
/**
|
|
22
|
+
* The latitude and longitude of the place, in degrees, for example,
|
|
23
|
+
* `{ latitude: 37.3317, longitude: -122.0301 }`.
|
|
24
|
+
*/
|
|
25
|
+
coordinates: Coordinates;
|
|
26
|
+
/**
|
|
27
|
+
* The name of the place, for example, `1 Infinite Loop`. Each platform reads this from its own
|
|
28
|
+
* field, so it can be a building, a street, a postcode or an administrative area.
|
|
29
|
+
*/
|
|
30
|
+
name: string | null;
|
|
31
|
+
/**
|
|
32
|
+
* The whole address on one line, for example,
|
|
33
|
+
* `1 Infinite Loop, Cupertino, CA 95014, United States`.
|
|
34
|
+
*/
|
|
35
|
+
formattedAddress: string | null;
|
|
36
|
+
/**
|
|
37
|
+
* The city name of the address, for example, `Cupertino`.
|
|
38
|
+
*
|
|
39
|
+
* This is `null` when the backend has no city for the place. That can happen even for a town you
|
|
40
|
+
* would name, in which case the city is often still part of `formattedAddress`.
|
|
41
|
+
*/
|
|
42
|
+
city: string | null;
|
|
43
|
+
/**
|
|
44
|
+
* The country name of the address, for example, `United States`.
|
|
45
|
+
*/
|
|
46
|
+
country: string | null;
|
|
47
|
+
/**
|
|
48
|
+
* The ISO 3166-1 alpha-2 country code of the address, for example, `US`.
|
|
49
|
+
*/
|
|
50
|
+
isoCountryCode: string | null;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Options for [`geocode`](#geocodeaddress-options).
|
|
55
|
+
* @platform android
|
|
56
|
+
* @platform ios
|
|
57
|
+
*/
|
|
58
|
+
export type GeocodeOptions = {
|
|
59
|
+
/**
|
|
60
|
+
* The language of the text fields in the result, as a BCP 47 tag such as `en-US`. Defaults to
|
|
61
|
+
* the device language.
|
|
62
|
+
*/
|
|
63
|
+
locale?: string;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Options for [`reverseGeocode`](#reversegeocodecoordinates-options).
|
|
68
|
+
* @platform android
|
|
69
|
+
* @platform ios
|
|
70
|
+
*/
|
|
71
|
+
export type ReverseGeocodeOptions = {
|
|
72
|
+
/**
|
|
73
|
+
* The language of the text fields in the result, as a BCP 47 tag such as `en-US`. Defaults to
|
|
74
|
+
* the device language.
|
|
75
|
+
*/
|
|
76
|
+
locale?: string;
|
|
77
|
+
};
|
package/src/next/types/index.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
9cd70fc8266a1f17601f49e84e3255d3
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2ab913e2508bb752970c222cf4906f023b772209
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
cd09575a93cfc2f28b138c1b4d479e407035cc991639a75e3da3e5a057170a28
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
18552c6609c50cfccd8b7cea5c9c1295a2df6e7080f4e8472681c4ea633376e94f43bcfbc70946391792d635dcd9c7c0688d4ab382b6b34f1add598d82916943
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
88320df8c179b0f8fcb669f696ab0f96
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
e619441840ee48b895ef8deac3cfdf03db006d02
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
d19b8691e52672f787c2f00f17b0bf4e134cd1af43cc3503f79c2c3bbb5bc8b8
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
d3eb631b8bd28712b804810b901ec3fe51d1eb83366f189d7c65490b905b9d08cf99775a9d9f0cb5dea2b5d735a232488619c78c482220ebf1d04d9fd48c6d6f
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
4c78fd3484417685f46e86bcd9332487
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
cff559c5cc359169068db2589ca1c563e08b3c24
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
db97545c9f956f7f2cefd08126e7c87c4c13e5bdd2b6e07e540fa99efefa5aff
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
58f9998ca00f996f8b21e963e78c55b803a945c7f6f3bb417d11641c87772a22bb4c85789cc5a22f3e59fcdc1a3a86747f4c58eeca66b4377bba44fbdaf50712
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3a09551b142a0a86c8febf6859bfae5c
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
513c9c09d5c51d3ccc65242cda09f2a366a9ae61
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
f4a7f9c2f80e1aef46cd6d86f27f13ad0c5d1fb2ac75448f086ca3ea705624f3
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
756ed9726cb961df2b65ad6d44d16c7547b7709829efbd6b820e82432c42827824c9b2a3c8e3b0c8c173ff91d2dc9a699fde8fa13d38db3423ad1c9af053cdad
|