expo-location 58.0.21 → 58.0.23
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 +15 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/location/LocationModule.kt +2 -5
- 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/Location.d.ts +5 -4
- package/build/Location.js +35 -17
- package/build/Location.js.map +1 -1
- package/build/Location.types.d.ts +12 -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/ios/next/Position/Position.swift +13 -3
- package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.21/expo.modules.location-58.0.21-sources.jar → 58.0.23/expo.modules.location-58.0.23-sources.jar} +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23-sources.jar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23-sources.jar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23-sources.jar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23-sources.jar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.aar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.aar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.aar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.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.23/expo.modules.location-58.0.23.module} +22 -22
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.module.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.module.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.module.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.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.23/expo.modules.location-58.0.23.pom} +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.pom.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.pom.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.pom.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.pom.sha512 +1 -0
- package/package.json +2 -2
- package/src/Location.ts +50 -19
- package/src/Location.types.ts +13 -0
- 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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 58.0.23
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [Android] Fix a `ConcurrentModificationException` crash in the motion activity receiver and stop `removeWatchAsync` from requiring the location permission. ([#53919](https://github.com/expo/expo/pull/53919) by [@HubertBer](https://github.com/HubertBer))
|
|
8
|
+
- Add a `timeout` option to `getMotionActivityAsync` that rejects with `ERR_LOCATION_MOTION_ACTIVITY_TIMEOUT` when no activity update arrives in time. ([#53920](https://github.com/expo/expo/pull/53920) by [@HubertBer](https://github.com/HubertBer))
|
|
9
|
+
- [next][iOS] Send `null` instead of omitting the unavailable `Position` fields in task and watcher payloads. ([#53093](https://github.com/expo/expo/pull/53093) by [@Wenszel](https://github.com/Wenszel))
|
|
10
|
+
|
|
11
|
+
## 58.0.22
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [Android] Add `geocode` and `reverseGeocode` to the `expo-location/next` API. ([#52444](https://github.com/expo/expo/pull/52444) by [@HubertBer](https://github.com/HubertBer))
|
|
16
|
+
- [next] Add `geocode` and `reverseGeocode` with a `locale` option. ([#52024](https://github.com/expo/expo/pull/52024) by [@Wenszel](https://github.com/Wenszel))
|
|
17
|
+
|
|
3
18
|
## 58.0.21
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/android/build.gradle
CHANGED
|
@@ -4,13 +4,13 @@ plugins {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
group = 'host.exp.exponent'
|
|
7
|
-
version = '58.0.
|
|
7
|
+
version = '58.0.23'
|
|
8
8
|
|
|
9
9
|
android {
|
|
10
10
|
namespace "expo.modules.location"
|
|
11
11
|
defaultConfig {
|
|
12
12
|
versionCode 29
|
|
13
|
-
versionName "58.0.
|
|
13
|
+
versionName "58.0.23"
|
|
14
14
|
consumerProguardFiles("proguard-rules.pro")
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -69,6 +69,7 @@ import kotlinx.coroutines.Dispatchers
|
|
|
69
69
|
import kotlinx.coroutines.suspendCancellableCoroutine
|
|
70
70
|
import kotlinx.coroutines.withContext
|
|
71
71
|
import java.util.Locale
|
|
72
|
+
import java.util.concurrent.ConcurrentHashMap
|
|
72
73
|
import kotlin.coroutines.resume
|
|
73
74
|
import kotlin.coroutines.resumeWithException
|
|
74
75
|
import kotlin.coroutines.suspendCoroutine
|
|
@@ -93,7 +94,7 @@ class LocationModule : Module(), SensorEventListener, ActivityEventListener {
|
|
|
93
94
|
private var mGeocoderPaused = false
|
|
94
95
|
|
|
95
96
|
// Motion activity
|
|
96
|
-
private val mMotionActivityWatchIds
|
|
97
|
+
private val mMotionActivityWatchIds: MutableSet<Int> = ConcurrentHashMap.newKeySet()
|
|
97
98
|
private var mMotionActivityPendingIntent: PendingIntent? = null
|
|
98
99
|
private var mMotionActivityReceiverRegistered = false
|
|
99
100
|
private val mMotionActivityReceiver = object : BroadcastReceiver() {
|
|
@@ -268,10 +269,6 @@ class LocationModule : Module(), SensorEventListener, ActivityEventListener {
|
|
|
268
269
|
return@AsyncFunction
|
|
269
270
|
}
|
|
270
271
|
|
|
271
|
-
if (isMissingForegroundPermissions()) {
|
|
272
|
-
throw LocationUnauthorizedException()
|
|
273
|
-
}
|
|
274
|
-
|
|
275
272
|
// Check if we want to stop watching location or compass
|
|
276
273
|
if (watchId == mHeadingId) {
|
|
277
274
|
destroyHeadingWatch()
|
|
@@ -15,6 +15,11 @@ import expo.modules.kotlin.modules.Module
|
|
|
15
15
|
import expo.modules.kotlin.modules.ModuleDefinition
|
|
16
16
|
import expo.modules.kotlin.functions.Coroutine
|
|
17
17
|
import expo.modules.kotlin.sharedobjects.SharedRef
|
|
18
|
+
import expo.modules.location.next.geocoding.GeocodeOptions
|
|
19
|
+
import expo.modules.location.next.geocoding.GeocodingQuery
|
|
20
|
+
import expo.modules.location.next.geocoding.InvalidCoordinatesException
|
|
21
|
+
import expo.modules.location.next.geocoding.geocode
|
|
22
|
+
import expo.modules.location.next.geocoding.ReverseGeocodeOptions
|
|
18
23
|
import expo.modules.location.next.locationForegroundService.BackgroundSessionOptions
|
|
19
24
|
import expo.modules.location.next.locationForegroundService.BackgroundSessionState
|
|
20
25
|
import expo.modules.location.next.locationForegroundService.LocationForegroundService
|
|
@@ -132,6 +137,30 @@ class LocationModuleNext : Module() {
|
|
|
132
137
|
return@Coroutine permissionsManager.getLocationPermissions(background = true)
|
|
133
138
|
}
|
|
134
139
|
|
|
140
|
+
AsyncFunction("geocode") Coroutine { address: String, options: GeocodeOptions? ->
|
|
141
|
+
if (address.isBlank()) {
|
|
142
|
+
return@Coroutine emptyList()
|
|
143
|
+
}
|
|
144
|
+
return@Coroutine geocode(
|
|
145
|
+
context,
|
|
146
|
+
appContext.jsLogger,
|
|
147
|
+
GeocodingQuery.ByAddress(address),
|
|
148
|
+
options?.locale
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
AsyncFunction("reverseGeocode") Coroutine { coordinates: Coordinates, options: ReverseGeocodeOptions? ->
|
|
153
|
+
if (!coordinates.areValid()) {
|
|
154
|
+
throw InvalidCoordinatesException()
|
|
155
|
+
}
|
|
156
|
+
return@Coroutine geocode(
|
|
157
|
+
context,
|
|
158
|
+
appContext.jsLogger,
|
|
159
|
+
GeocodingQuery.ByCoordinates(coordinates),
|
|
160
|
+
options?.locale
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
|
|
135
164
|
AsyncFunction("requestNotificationPermissions") Coroutine { ->
|
|
136
165
|
permissionsManager.requestNotificationPermissions()
|
|
137
166
|
return@Coroutine permissionsManager.getNotificationPermissions(context)
|
|
@@ -7,6 +7,7 @@ import android.os.Bundle
|
|
|
7
7
|
import android.os.PersistableBundle
|
|
8
8
|
import expo.modules.kotlin.records.Field
|
|
9
9
|
import expo.modules.kotlin.records.Record
|
|
10
|
+
import expo.modules.kotlin.records.Required
|
|
10
11
|
import expo.modules.kotlin.types.Enumerable
|
|
11
12
|
import expo.modules.kotlin.types.OptimizedRecord
|
|
12
13
|
import expo.modules.location.next.locationProviders.BackgroundUpdatesParameters
|
|
@@ -126,8 +127,8 @@ class GetPositionOptions(
|
|
|
126
127
|
|
|
127
128
|
@OptimizedRecord
|
|
128
129
|
class Coordinates(
|
|
129
|
-
@Field val latitude: Double,
|
|
130
|
-
@Field val longitude: Double
|
|
130
|
+
@Field @Required val latitude: Double,
|
|
131
|
+
@Field @Required val longitude: Double
|
|
131
132
|
) : Record {
|
|
132
133
|
private fun BaseBundle.putCoordinateFields() {
|
|
133
134
|
putDouble("latitude", latitude)
|
|
@@ -139,6 +140,9 @@ class Coordinates(
|
|
|
139
140
|
fun toBundle() = Bundle().apply { putCoordinateFields() }
|
|
140
141
|
}
|
|
141
142
|
|
|
143
|
+
fun Coordinates.areValid(): Boolean =
|
|
144
|
+
latitude in -90.0..90.0 && longitude in -180.0..180.0
|
|
145
|
+
|
|
142
146
|
fun PersistableBundle.toCoordinates(): Coordinates = Coordinates(
|
|
143
147
|
getDouble("latitude"),
|
|
144
148
|
getDouble("longitude")
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
package expo.modules.location.next.geocoding
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.location.Address as AndroidAddress
|
|
5
|
+
import android.location.Geocoder
|
|
6
|
+
import android.os.Build
|
|
7
|
+
import androidx.annotation.DeprecatedSinceApi
|
|
8
|
+
import androidx.annotation.RequiresApi
|
|
9
|
+
import expo.modules.core.logging.Logger
|
|
10
|
+
import expo.modules.location.next.Coordinates
|
|
11
|
+
import java.io.IOException
|
|
12
|
+
import java.util.Locale
|
|
13
|
+
import kotlin.coroutines.resume
|
|
14
|
+
import kotlin.coroutines.resumeWithException
|
|
15
|
+
import kotlinx.coroutines.CancellationException
|
|
16
|
+
import kotlinx.coroutines.Dispatchers
|
|
17
|
+
import kotlinx.coroutines.suspendCancellableCoroutine
|
|
18
|
+
import kotlinx.coroutines.withContext
|
|
19
|
+
|
|
20
|
+
private const val MAX_GEOCODING_RESULTS = 4
|
|
21
|
+
|
|
22
|
+
sealed interface GeocodingQuery {
|
|
23
|
+
data class ByAddress(val address: String) : GeocodingQuery
|
|
24
|
+
data class ByCoordinates(val coordinates: Coordinates) : GeocodingQuery
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private suspend fun Geocoder.findAddresses(query: GeocodingQuery): List<AndroidAddress> {
|
|
28
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
29
|
+
return findAddressesModern(query)
|
|
30
|
+
}
|
|
31
|
+
return findAddressesLegacy(query)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
|
|
35
|
+
private suspend fun Geocoder.findAddressesModern(query: GeocodingQuery): List<AndroidAddress> =
|
|
36
|
+
suspendCancellableCoroutine { continuation ->
|
|
37
|
+
val listener = object : Geocoder.GeocodeListener {
|
|
38
|
+
override fun onGeocode(addresses: MutableList<AndroidAddress>) {
|
|
39
|
+
continuation.resume(addresses)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
override fun onError(errorMessage: String?) {
|
|
43
|
+
continuation.resumeWithException(IOException(errorMessage))
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
when (query) {
|
|
47
|
+
is GeocodingQuery.ByAddress ->
|
|
48
|
+
getFromLocationName(query.address, MAX_GEOCODING_RESULTS, listener)
|
|
49
|
+
is GeocodingQuery.ByCoordinates ->
|
|
50
|
+
getFromLocation(query.coordinates.latitude, query.coordinates.longitude, MAX_GEOCODING_RESULTS, listener)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@DeprecatedSinceApi(Build.VERSION_CODES.TIRAMISU)
|
|
55
|
+
private suspend fun Geocoder.findAddressesLegacy(query: GeocodingQuery): List<AndroidAddress> =
|
|
56
|
+
withContext(Dispatchers.IO) {
|
|
57
|
+
when (query) {
|
|
58
|
+
is GeocodingQuery.ByAddress ->
|
|
59
|
+
getFromLocationName(query.address, MAX_GEOCODING_RESULTS)
|
|
60
|
+
is GeocodingQuery.ByCoordinates ->
|
|
61
|
+
getFromLocation(query.coordinates.latitude, query.coordinates.longitude, MAX_GEOCODING_RESULTS)
|
|
62
|
+
}.orEmpty()
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private fun AndroidAddress.toAddress(): Address? {
|
|
66
|
+
if (!hasLatitude() || !hasLongitude()) {
|
|
67
|
+
return null
|
|
68
|
+
}
|
|
69
|
+
return Address(
|
|
70
|
+
coordinates = Coordinates(latitude, longitude),
|
|
71
|
+
name = featureName?.takeIf { it.isNotBlank() },
|
|
72
|
+
formattedAddress = formattedAddressOrNull(),
|
|
73
|
+
city = locality?.takeIf { it.isNotBlank() },
|
|
74
|
+
country = countryName?.takeIf { it.isNotBlank() },
|
|
75
|
+
isoCountryCode = countryCode?.takeIf { it.isNotBlank() }
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private fun AndroidAddress.formattedAddressOrNull(): String? {
|
|
80
|
+
return (0..maxAddressLineIndex)
|
|
81
|
+
.mapNotNull { getAddressLine(it) }
|
|
82
|
+
.filter { it.isNotBlank() }
|
|
83
|
+
.joinToString(", ")
|
|
84
|
+
.takeIf { it.isNotBlank() }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private fun resolveLocale(locale: String?, logger: Logger?): Locale {
|
|
88
|
+
val requestedLocale = locale ?: return Locale.getDefault()
|
|
89
|
+
val parsedLocale = Locale.forLanguageTag(requestedLocale)
|
|
90
|
+
if (parsedLocale.language.isEmpty()) {
|
|
91
|
+
logger?.warn("[expo-location] Unrecognized locale '$requestedLocale', the device locale will be used instead.")
|
|
92
|
+
return Locale.getDefault()
|
|
93
|
+
}
|
|
94
|
+
return parsedLocale
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
suspend fun geocode(
|
|
98
|
+
context: Context,
|
|
99
|
+
logger: Logger?,
|
|
100
|
+
query: GeocodingQuery,
|
|
101
|
+
locale: String?
|
|
102
|
+
): List<Address> {
|
|
103
|
+
if (!Geocoder.isPresent()) {
|
|
104
|
+
throw NoGeocodingBackendException()
|
|
105
|
+
}
|
|
106
|
+
val resolvedLocale = resolveLocale(locale, logger)
|
|
107
|
+
val results = try {
|
|
108
|
+
Geocoder(context, resolvedLocale).findAddresses(query)
|
|
109
|
+
} catch (exception: CancellationException) {
|
|
110
|
+
throw exception
|
|
111
|
+
} catch (exception: IOException) {
|
|
112
|
+
throw GeocodingUnavailableException(exception)
|
|
113
|
+
} catch (exception: RuntimeException) {
|
|
114
|
+
throw GeocodingFailedException(exception)
|
|
115
|
+
}
|
|
116
|
+
return results.mapNotNull { it.toAddress() }
|
|
117
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
package expo.modules.location.next.geocoding
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.exception.CodedException
|
|
4
|
+
|
|
5
|
+
class NoGeocodingBackendException :
|
|
6
|
+
CodedException(
|
|
7
|
+
"This device has no geocoding backend. `android.location.Geocoder` is served by a backend " +
|
|
8
|
+
"that is not part of the core Android framework, and devices without it - including many " +
|
|
9
|
+
"without Google Play services - cannot geocode at all. Reconnecting to the network does " +
|
|
10
|
+
"not help."
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
class InvalidCoordinatesException :
|
|
14
|
+
CodedException(
|
|
15
|
+
"The coordinates are outside the valid range. Latitude must be between -90 and 90, " +
|
|
16
|
+
"longitude between -180 and 180."
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
class GeocodingUnavailableException(cause: Throwable? = null) :
|
|
20
|
+
CodedException(
|
|
21
|
+
"The geocoding service could not be reached. This is usually a network failure or a timeout, " +
|
|
22
|
+
"and retrying later may succeed.",
|
|
23
|
+
cause
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
class GeocodingFailedException(cause: Throwable) :
|
|
27
|
+
CodedException("Geocoding failed.", cause)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package expo.modules.location.next.geocoding
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.records.Field
|
|
4
|
+
import expo.modules.kotlin.records.Record
|
|
5
|
+
import expo.modules.kotlin.types.OptimizedRecord
|
|
6
|
+
import expo.modules.location.next.Coordinates
|
|
7
|
+
|
|
8
|
+
@OptimizedRecord
|
|
9
|
+
class Address(
|
|
10
|
+
@Field val coordinates: Coordinates,
|
|
11
|
+
@Field val name: String?,
|
|
12
|
+
@Field val formattedAddress: String?,
|
|
13
|
+
@Field val city: String?,
|
|
14
|
+
@Field val country: String?,
|
|
15
|
+
@Field val isoCountryCode: String?
|
|
16
|
+
) : Record
|
|
17
|
+
|
|
18
|
+
class GeocodeOptions(
|
|
19
|
+
@Field val locale: String? = null
|
|
20
|
+
) : Record
|
|
21
|
+
|
|
22
|
+
class ReverseGeocodeOptions(
|
|
23
|
+
@Field val locale: String? = null
|
|
24
|
+
) : Record
|
package/build/Location.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PermissionResponse } from 'expo';
|
|
2
|
-
import type { LocationErrorCallback, LocationCallback, LocationGeocodedAddress, LocationGeocodedLocation, LocationHeadingCallback, LocationHeadingObject, LocationLastKnownOptions, LocationObject, LocationOptions, LocationPermissionResponse, LocationProviderStatus, LocationRegion, LocationSubscription, LocationTaskOptions, MotionActivityCallback, MotionActivityObject } from './Location.types';
|
|
2
|
+
import type { LocationErrorCallback, LocationCallback, LocationGeocodedAddress, LocationGeocodedLocation, LocationHeadingCallback, LocationHeadingObject, LocationLastKnownOptions, LocationObject, LocationOptions, LocationPermissionResponse, LocationProviderStatus, LocationRegion, LocationSubscription, LocationTaskOptions, MotionActivityCallback, MotionActivityObject, MotionActivityOptions } from './Location.types';
|
|
3
3
|
/**
|
|
4
4
|
* Check status of location providers.
|
|
5
5
|
* @return A promise which fulfills with an object of type [`LocationProviderStatus`](#locationproviderstatus).
|
|
@@ -198,13 +198,14 @@ export declare const useMotionActivityPermissions: (options?: import("expo-modul
|
|
|
198
198
|
* On Android 10+, the `ACTIVITY_RECOGNITION` runtime permission must be granted beforehand.
|
|
199
199
|
* On iOS, the system will prompt the user for Motion and Fitness access the first time this method is called.
|
|
200
200
|
*
|
|
201
|
-
*
|
|
202
|
-
* @return
|
|
201
|
+
* @param options Options for the call. See [`MotionActivityOptions`](#motionactivityoptions).
|
|
202
|
+
* @return A promise which fulfills with a [`MotionActivityObject`](#motionactivityobject), or
|
|
203
|
+
* rejects with `ERR_LOCATION_MOTION_ACTIVITY_TIMEOUT` when `timeout` passes first.
|
|
203
204
|
*
|
|
204
205
|
* @platform android
|
|
205
206
|
* @platform ios
|
|
206
207
|
*/
|
|
207
|
-
export declare function getMotionActivityAsync(): Promise<MotionActivityObject>;
|
|
208
|
+
export declare function getMotionActivityAsync({ timeout, }?: MotionActivityOptions): Promise<MotionActivityObject>;
|
|
208
209
|
/**
|
|
209
210
|
* Subscribes to motion activity updates from the device. The callback fires whenever the
|
|
210
211
|
* platform's motion coprocessor detects a change in the user's activity. Only foreground use
|
package/build/Location.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createPermissionHook, isRunningInExpoGo, Platform } from 'expo';
|
|
1
|
+
import { CodedError, createPermissionHook, isRunningInExpoGo, Platform } from 'expo';
|
|
2
2
|
import ExpoLocation from './ExpoLocation';
|
|
3
3
|
import { LocationAccuracy } from './Location.types';
|
|
4
4
|
import { LocationSubscriber, HeadingSubscriber, LocationErrorSubscriber, MotionActivitySubscriber } from './LocationSubscribers';
|
|
@@ -300,26 +300,44 @@ let warnAboutExpoGoDisplayed = false;
|
|
|
300
300
|
* On Android 10+, the `ACTIVITY_RECOGNITION` runtime permission must be granted beforehand.
|
|
301
301
|
* On iOS, the system will prompt the user for Motion and Fitness access the first time this method is called.
|
|
302
302
|
*
|
|
303
|
-
*
|
|
304
|
-
* @return
|
|
303
|
+
* @param options Options for the call. See [`MotionActivityOptions`](#motionactivityoptions).
|
|
304
|
+
* @return A promise which fulfills with a [`MotionActivityObject`](#motionactivityobject), or
|
|
305
|
+
* rejects with `ERR_LOCATION_MOTION_ACTIVITY_TIMEOUT` when `timeout` passes first.
|
|
305
306
|
*
|
|
306
307
|
* @platform android
|
|
307
308
|
* @platform ios
|
|
308
|
-
*/ export async function getMotionActivityAsync() {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
309
|
+
*/ export async function getMotionActivityAsync({ timeout } = {}) {
|
|
310
|
+
assertValidTimeout(timeout);
|
|
311
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
312
|
+
const subscriber = await watchMotionActivityAsync(resolve, (reason)=>reject(new Error(reason)));
|
|
313
|
+
try {
|
|
314
|
+
return await withTimeout(promise, timeout);
|
|
315
|
+
} finally{
|
|
316
|
+
subscriber.remove();
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
function assertValidTimeout(timeout) {
|
|
320
|
+
if (timeout === undefined) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
if (!Number.isFinite(timeout) || timeout <= 0) {
|
|
324
|
+
throw new CodedError('ERR_LOCATION_INVALID_TIMEOUT', `\`timeout\` must be a positive, finite number of milliseconds. Got ${timeout} instead.`);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
function withTimeout(promise, timeout) {
|
|
328
|
+
if (timeout === undefined) {
|
|
329
|
+
return promise;
|
|
330
|
+
}
|
|
331
|
+
let timer;
|
|
332
|
+
const timedOut = new Promise((_, reject)=>{
|
|
333
|
+
timer = setTimeout(()=>{
|
|
334
|
+
reject(new CodedError('ERR_LOCATION_MOTION_ACTIVITY_TIMEOUT', `No motion activity update arrived within ${timeout} ms.`));
|
|
335
|
+
}, timeout);
|
|
322
336
|
});
|
|
337
|
+
return Promise.race([
|
|
338
|
+
promise,
|
|
339
|
+
timedOut
|
|
340
|
+
]).finally(()=>clearTimeout(timer));
|
|
323
341
|
}
|
|
324
342
|
/**
|
|
325
343
|
* Subscribes to motion activity updates from the device. The callback fires whenever the
|
package/build/Location.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Location.ts"],"sourcesContent":[null],"names":["createPermissionHook","isRunningInExpoGo","Platform","ExpoLocation","LocationAccuracy","LocationSubscriber","HeadingSubscriber","LocationErrorSubscriber","MotionActivitySubscriber","warnAboutExpoGoDisplayed","getProviderStatusAsync","enableNetworkProviderAsync","OS","getCurrentPositionAsync","options","getLastKnownPositionAsync","watchPositionAsync","callback","errorHandler","watchId","registerCallback","registerCallbackForId","watchPositionImplAsync","remove","unregisterCallback","getHeadingAsync","Promise","resolve","reject","tries","subscriber","undefined","watchHeadingAsync","heading","accuracy","reason","e","watchDeviceHeading","geocodeAsync","address","TypeError","__DEV__","console","warn","reverseGeocodeAsync","location","latitude","longitude","getForegroundPermissionsAsync","requestForegroundPermissionsAsync","useForegroundPermissions","getMethod","requestMethod","getBackgroundPermissionsAsync","requestBackgroundPermissionsAsync","useBackgroundPermissions","hasServicesEnabledAsync","getMotionActivityPermissionsAsync","requestMotionActivityPermissionsAsync","useMotionActivityPermissions","getMotionActivityAsync","
|
|
1
|
+
{"version":3,"sources":["Location.ts"],"sourcesContent":[null],"names":["CodedError","createPermissionHook","isRunningInExpoGo","Platform","ExpoLocation","LocationAccuracy","LocationSubscriber","HeadingSubscriber","LocationErrorSubscriber","MotionActivitySubscriber","warnAboutExpoGoDisplayed","getProviderStatusAsync","enableNetworkProviderAsync","OS","getCurrentPositionAsync","options","getLastKnownPositionAsync","watchPositionAsync","callback","errorHandler","watchId","registerCallback","registerCallbackForId","watchPositionImplAsync","remove","unregisterCallback","getHeadingAsync","Promise","resolve","reject","tries","subscriber","undefined","watchHeadingAsync","heading","accuracy","reason","e","watchDeviceHeading","geocodeAsync","address","TypeError","__DEV__","console","warn","reverseGeocodeAsync","location","latitude","longitude","getForegroundPermissionsAsync","requestForegroundPermissionsAsync","useForegroundPermissions","getMethod","requestMethod","getBackgroundPermissionsAsync","requestBackgroundPermissionsAsync","useBackgroundPermissions","hasServicesEnabledAsync","getMotionActivityPermissionsAsync","requestMotionActivityPermissionsAsync","useMotionActivityPermissions","getMotionActivityAsync","timeout","assertValidTimeout","promise","withResolvers","watchMotionActivityAsync","Error","withTimeout","Number","isFinite","timer","timedOut","_","setTimeout","race","finally","clearTimeout","watchMotionActivityImplAsync","forgetCallback","_validate","taskName","message","isBackgroundLocationAvailableAsync","providerStatus","backgroundModeEnabled","startLocationUpdatesAsync","Balanced","stopLocationUpdatesAsync","hasStartedLocationUpdatesAsync","_validateRegions","regions","length","region","radius","startGeofencingAsync","stopGeofencingAsync","hasStartedGeofencingAsync"],"mappings":"AAAA,SACEA,UAAU,EACVC,oBAAoB,EACpBC,iBAAiB,EACjBC,QAAQ,QAEH,OAAO;AAEd,OAAOC,kBAAkB,iBAAiB;AAoB1C,SAASC,gBAAgB,QAAQ,mBAAmB;AACpD,SACEC,kBAAkB,EAClBC,iBAAiB,EACjBC,uBAAuB,EACvBC,wBAAwB,QACnB,wBAAwB;AAE/B,4EAA4E;AAC5E,IAAIC,2BAA2B;AAE/B,cAAc;AACd;;;CAGC,GACD,OAAO,eAAeC;IACpB,OAAOP,aAAaO,sBAAsB;AAC5C;AAEA,cAAc;AACd;;;;;;CAMC,GACD,OAAO,eAAeC;IACpB,kFAAkF;IAClF,qGAAqG;IACrG,+GAA+G;IAC/G,wFAAwF;IAExF,IAAIT,SAASU,EAAE,KAAK,WAAW;QAC7B,OAAOT,aAAaQ,0BAA0B;IAChD;AACF;AAEA,cAAc;AACd;;;;;;;;;CASC,GACD,OAAO,eAAeE,wBACpBC,UAA2B,CAAC,CAAC;IAE7B,OAAOX,aAAaU,uBAAuB,CAACC;AAC9C;AAEA,cAAc;AACd;;;;;;;;;CASC,GACD,OAAO,eAAeC,0BACpBD,UAAoC,CAAC,CAAC;IAEtC,OAAOX,aAAaY,yBAAyB,CAACD;AAChD;AAEA,cAAc;AACd;;;;;;;;;;CAUC,GACD,OAAO,eAAeE,mBACpBF,OAAwB,EACxBG,QAA0B,EAC1BC,YAAoC;IAEpC,MAAMC,UAAUd,mBAAmBe,gBAAgB,CAACH;IACpDC,gBAAgBX,wBAAwBc,qBAAqB,CAACF,SAASD;IAEvE,MAAMf,aAAamB,sBAAsB,CAACH,SAASL;IAEnD,OAAO;QACLS;YACElB,mBAAmBmB,kBAAkB,CAACL;YACtCD,gBAAgBX,wBAAwBiB,kBAAkB,CAACL;QAC7D;IACF;AACF;AAEA,cAAc;A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U,CAAC;QAE7E;QACA,IAAI,OAAO6C,OAAOC,MAAM,KAAK,UAAU;YACrC,MAAM,IAAIrD,UAAU,CAAC,uCAAuC,EAAEoD,OAAOC,MAAM,CAAC,UAAU,CAAC;QACzF;IACF;AACF;AAEA,cAAc;AACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCC,GACD,OAAO,eAAeC,qBACpBd,QAAgB,EAChBU,UAA4B,EAAE;IAE9BX,UAAUC;IACVS,iBAAiBC;IACjB,MAAMvF,aAAa2F,oBAAoB,CAACd,UAAU;QAAEU;IAAQ;AAC9D;AAEA,cAAc;AACd;;;;;CAKC,GACD,OAAO,eAAeK,oBAAoBf,QAAgB;IACxDD,UAAUC;IACV,MAAM7E,aAAa4F,mBAAmB,CAACf;AACzC;AAEA,cAAc;AACd;;;;CAIC,GACD,OAAO,eAAegB,0BAA0BhB,QAAgB;IAC9DD,UAAUC;IACV,OAAO7E,aAAa6F,yBAAyB,CAAChB;AAChD"}
|
|
@@ -560,6 +560,18 @@ export type MotionActivityObject = {
|
|
|
560
560
|
*/
|
|
561
561
|
timestamp: number;
|
|
562
562
|
};
|
|
563
|
+
/**
|
|
564
|
+
* Options for `getMotionActivityAsync`.
|
|
565
|
+
*/
|
|
566
|
+
export type MotionActivityOptions = {
|
|
567
|
+
/**
|
|
568
|
+
* The maximum time to wait for an activity update, in milliseconds. When it passes, the promise
|
|
569
|
+
* rejects with an error whose `code` is `ERR_LOCATION_MOTION_ACTIVITY_TIMEOUT`. Without it the
|
|
570
|
+
* promise waits for the next activity update. That can take a long time if the device is still
|
|
571
|
+
* or the app is in the background.
|
|
572
|
+
*/
|
|
573
|
+
timeout?: number;
|
|
574
|
+
};
|
|
563
575
|
/**
|
|
564
576
|
* Represents the `watchMotionActivityAsync` callback.
|
|
565
577
|
*/
|
package/build/next/Location.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { getPosition, watchPosition, hasLocationServicesEnabled, enableLocationServices, getForegroundPermissions, requestForegroundPermissions, getBackgroundPermissions, requestBackgroundPermissions, getNotificationPermissions, requestNotificationPermissions, setLocationProvider, getSelectedLocationProviderName, ensureBackgroundSessionStarted, stopBackgroundSession, getBackgroundSessionStatus, } from './js';
|
|
1
|
+
export { getPosition, watchPosition, hasLocationServicesEnabled, enableLocationServices, getForegroundPermissions, requestForegroundPermissions, getBackgroundPermissions, requestBackgroundPermissions, getNotificationPermissions, requestNotificationPermissions, setLocationProvider, getSelectedLocationProviderName, ensureBackgroundSessionStarted, stopBackgroundSession, getBackgroundSessionStatus, geocode, reverseGeocode, } from './js';
|
package/build/next/Location.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { getPosition, watchPosition, hasLocationServicesEnabled, enableLocationServices, getForegroundPermissions, requestForegroundPermissions, getBackgroundPermissions, requestBackgroundPermissions, getNotificationPermissions, requestNotificationPermissions, setLocationProvider, getSelectedLocationProviderName, ensureBackgroundSessionStarted, stopBackgroundSession, getBackgroundSessionStatus } from './js';
|
|
1
|
+
export { getPosition, watchPosition, hasLocationServicesEnabled, enableLocationServices, getForegroundPermissions, requestForegroundPermissions, getBackgroundPermissions, requestBackgroundPermissions, getNotificationPermissions, requestNotificationPermissions, setLocationProvider, getSelectedLocationProviderName, ensureBackgroundSessionStarted, stopBackgroundSession, getBackgroundSessionStatus, geocode, reverseGeocode } from './js';
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=Location.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["next/Location.ts"],"sourcesContent":[null],"names":["getPosition","watchPosition","hasLocationServicesEnabled","enableLocationServices","getForegroundPermissions","requestForegroundPermissions","getBackgroundPermissions","requestBackgroundPermissions","getNotificationPermissions","requestNotificationPermissions","setLocationProvider","getSelectedLocationProviderName","ensureBackgroundSessionStarted","stopBackgroundSession","getBackgroundSessionStatus"],"mappings":"AAAA,SACEA,WAAW,EACXC,aAAa,EACbC,0BAA0B,EAC1BC,sBAAsB,EACtBC,wBAAwB,EACxBC,4BAA4B,EAC5BC,wBAAwB,EACxBC,4BAA4B,EAC5BC,0BAA0B,EAC1BC,8BAA8B,EAC9BC,mBAAmB,EACnBC,+BAA+B,EAC/BC,8BAA8B,EAC9BC,qBAAqB,EACrBC,0BAA0B,
|
|
1
|
+
{"version":3,"sources":["next/Location.ts"],"sourcesContent":[null],"names":["getPosition","watchPosition","hasLocationServicesEnabled","enableLocationServices","getForegroundPermissions","requestForegroundPermissions","getBackgroundPermissions","requestBackgroundPermissions","getNotificationPermissions","requestNotificationPermissions","setLocationProvider","getSelectedLocationProviderName","ensureBackgroundSessionStarted","stopBackgroundSession","getBackgroundSessionStatus","geocode","reverseGeocode"],"mappings":"AAAA,SACEA,WAAW,EACXC,aAAa,EACbC,0BAA0B,EAC1BC,sBAAsB,EACtBC,wBAAwB,EACxBC,4BAA4B,EAC5BC,wBAAwB,EACxBC,4BAA4B,EAC5BC,0BAA0B,EAC1BC,8BAA8B,EAC9BC,mBAAmB,EACnBC,+BAA+B,EAC/BC,8BAA8B,EAC9BC,qBAAqB,EACrBC,0BAA0B,EAC1BC,OAAO,EACPC,cAAc,QACT,OAAO"}
|
package/build/next/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * as Location from './Location';
|
|
2
2
|
export { useForegroundLocationPermissions, useBackgroundLocationPermissions, useNotificationPermissions, useLocationServices, PositionWatchHandle, LocationProvider, LocationUpdatesHandle, defineLocationTask, } from './js';
|
|
3
|
-
export { LocationProfile, LocationAccuracy, LocationScope, RequestPermissionsAccuracyOption, type Coordinates, type Position, type PositionUpdate, type PositionWatchError, type PositionWatchStatus, type WatchPositionParams, type GetPositionOptions, type LocationTaskOptions, type LocationPermissionResponse, type RequestPermissionsOptions, type LocationProviderRefType, BackgroundSessionState, type BackgroundSessionOptions, type BackgroundSessionStatus, type BackgroundTaskStatus, } from './types';
|
|
3
|
+
export { LocationProfile, LocationAccuracy, LocationScope, RequestPermissionsAccuracyOption, type Coordinates, type Position, type PositionUpdate, type PositionWatchError, type PositionWatchStatus, type WatchPositionParams, type GetPositionOptions, type LocationTaskOptions, type LocationPermissionResponse, type RequestPermissionsOptions, type LocationProviderRefType, BackgroundSessionState, type BackgroundSessionOptions, type BackgroundSessionStatus, type BackgroundTaskStatus, type Address, type GeocodeOptions, type ReverseGeocodeOptions, } from './types';
|
package/build/next/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["next/index.ts"],"sourcesContent":[null],"names":["Location","useForegroundLocationPermissions","useBackgroundLocationPermissions","useNotificationPermissions","useLocationServices","PositionWatchHandle","LocationProvider","LocationUpdatesHandle","defineLocationTask","LocationProfile","LocationAccuracy","LocationScope","RequestPermissionsAccuracyOption","BackgroundSessionState"],"mappings":"AAAA,OAAO,KAAKA,QAAQ,MAAM,aAAa;AAEvC,SACEC,gCAAgC,EAChCC,gCAAgC,EAChCC,0BAA0B,EAC1BC,mBAAmB,EACnBC,mBAAmB,EACnBC,gBAAgB,EAChBC,qBAAqB,EACrBC,kBAAkB,QACb,OAAO;AAEd,SACEC,eAAe,EACfC,gBAAgB,EAChBC,aAAa,EACbC,gCAAgC,EAYhCC,sBAAsB,
|
|
1
|
+
{"version":3,"sources":["next/index.ts"],"sourcesContent":[null],"names":["Location","useForegroundLocationPermissions","useBackgroundLocationPermissions","useNotificationPermissions","useLocationServices","PositionWatchHandle","LocationProvider","LocationUpdatesHandle","defineLocationTask","LocationProfile","LocationAccuracy","LocationScope","RequestPermissionsAccuracyOption","BackgroundSessionState"],"mappings":"AAAA,OAAO,KAAKA,QAAQ,MAAM,aAAa;AAEvC,SACEC,gCAAgC,EAChCC,gCAAgC,EAChCC,0BAA0B,EAC1BC,mBAAmB,EACnBC,mBAAmB,EACnBC,gBAAgB,EAChBC,qBAAqB,EACrBC,kBAAkB,QACb,OAAO;AAEd,SACEC,eAAe,EACfC,gBAAgB,EAChBC,aAAa,EACbC,gCAAgC,EAYhCC,sBAAsB,QAOjB,UAAU"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Address, Coordinates, GeocodeOptions, ReverseGeocodeOptions } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Finds the places that match an address string. Requires a network connection.
|
|
4
|
+
*
|
|
5
|
+
* @param address The text to look up, for example, `1 Infinite Loop, Cupertino`.
|
|
6
|
+
* @param options The language of the result.
|
|
7
|
+
* @return A promise that resolves to the matching addresses, or to an empty array when there are none.
|
|
8
|
+
* @throws When the device has no geocoding backend, geocoding is unavailable, or the request fails.
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const [match] = await Location.geocode('1 Infinite Loop, Cupertino');
|
|
12
|
+
* if (match) {
|
|
13
|
+
* console.log(match.coordinates.latitude, match.coordinates.longitude);
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
* @platform android
|
|
17
|
+
* @platform ios
|
|
18
|
+
*/
|
|
19
|
+
export declare function geocode(address: string, options?: GeocodeOptions): Promise<Address[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Finds the addresses at the given coordinates. Requires a network connection.
|
|
22
|
+
*
|
|
23
|
+
* @param coordinates The point to look up.
|
|
24
|
+
* @param options The language of the result.
|
|
25
|
+
* @return A promise that resolves to the addresses at the point, or to an empty array when there are none.
|
|
26
|
+
* @throws When the coordinates are invalid, the device has no geocoding backend, geocoding is unavailable, or the request fails.
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const position = await Location.getPosition();
|
|
30
|
+
* if (position) {
|
|
31
|
+
* const [address] = await Location.reverseGeocode(position.coordinates);
|
|
32
|
+
* console.log(address?.formattedAddress);
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
* @platform android
|
|
36
|
+
* @platform ios
|
|
37
|
+
*/
|
|
38
|
+
export declare function reverseGeocode(coordinates: Coordinates, options?: ReverseGeocodeOptions): Promise<Address[]>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Platform, UnavailabilityError } from 'expo';
|
|
2
|
+
import { NativeLocationModuleNext } from '../native';
|
|
3
|
+
/**
|
|
4
|
+
* Finds the places that match an address string. Requires a network connection.
|
|
5
|
+
*
|
|
6
|
+
* @param address The text to look up, for example, `1 Infinite Loop, Cupertino`.
|
|
7
|
+
* @param options The language of the result.
|
|
8
|
+
* @return A promise that resolves to the matching addresses, or to an empty array when there are none.
|
|
9
|
+
* @throws When the device has no geocoding backend, geocoding is unavailable, or the request fails.
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const [match] = await Location.geocode('1 Infinite Loop, Cupertino');
|
|
13
|
+
* if (match) {
|
|
14
|
+
* console.log(match.coordinates.latitude, match.coordinates.longitude);
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
* @platform android
|
|
18
|
+
* @platform ios
|
|
19
|
+
*/ export async function geocode(address, options) {
|
|
20
|
+
if (Platform.OS !== 'android' && Platform.OS !== 'ios') {
|
|
21
|
+
throw new UnavailabilityError('expo-location', 'geocode');
|
|
22
|
+
}
|
|
23
|
+
return NativeLocationModuleNext.geocode(address, options);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Finds the addresses at the given coordinates. Requires a network connection.
|
|
27
|
+
*
|
|
28
|
+
* @param coordinates The point to look up.
|
|
29
|
+
* @param options The language of the result.
|
|
30
|
+
* @return A promise that resolves to the addresses at the point, or to an empty array when there are none.
|
|
31
|
+
* @throws When the coordinates are invalid, the device has no geocoding backend, geocoding is unavailable, or the request fails.
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* const position = await Location.getPosition();
|
|
35
|
+
* if (position) {
|
|
36
|
+
* const [address] = await Location.reverseGeocode(position.coordinates);
|
|
37
|
+
* console.log(address?.formattedAddress);
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
* @platform android
|
|
41
|
+
* @platform ios
|
|
42
|
+
*/ export async function reverseGeocode(coordinates, options) {
|
|
43
|
+
if (Platform.OS !== 'android' && Platform.OS !== 'ios') {
|
|
44
|
+
throw new UnavailabilityError('expo-location', 'reverseGeocode');
|
|
45
|
+
}
|
|
46
|
+
return NativeLocationModuleNext.reverseGeocode(coordinates, options);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=geocoding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["next/js/geocoding.ts"],"sourcesContent":[null],"names":["Platform","UnavailabilityError","NativeLocationModuleNext","geocode","address","options","OS","reverseGeocode","coordinates"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,mBAAmB,QAAQ,OAAO;AAErD,SAASC,wBAAwB,QAAQ,YAAY;AAGrD;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,eAAeC,QAAQC,OAAe,EAAEC,OAAwB;IACrE,IAAIL,SAASM,EAAE,KAAK,aAAaN,SAASM,EAAE,KAAK,OAAO;QACtD,MAAM,IAAIL,oBAAoB,iBAAiB;IACjD;IACA,OAAOC,yBAAyBC,OAAO,CAACC,SAASC;AACnD;AAEA;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,eAAeE,eACpBC,WAAwB,EACxBH,OAA+B;IAE/B,IAAIL,SAASM,EAAE,KAAK,aAAaN,SAASM,EAAE,KAAK,OAAO;QACtD,MAAM,IAAIL,oBAAoB,iBAAiB;IACjD;IACA,OAAOC,yBAAyBK,cAAc,CAACC,aAAaH;AAC9D"}
|
package/build/next/js/index.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ export { LocationProvider, setLocationProvider, getSelectedLocationProviderName,
|
|
|
5
5
|
export { getForegroundPermissions, requestForegroundPermissions, getBackgroundPermissions, requestBackgroundPermissions, getNotificationPermissions, requestNotificationPermissions, useForegroundLocationPermissions, useBackgroundLocationPermissions, useNotificationPermissions, } from './Permissions';
|
|
6
6
|
export { LocationUpdatesHandle, defineLocationTask } from './LocationUpdatesHandle';
|
|
7
7
|
export { ensureBackgroundSessionStarted, stopBackgroundSession, getBackgroundSessionStatus, } from './BackgroundSession';
|
|
8
|
+
export { geocode, reverseGeocode } from './geocoding';
|
package/build/next/js/index.js
CHANGED
|
@@ -5,5 +5,6 @@ export { LocationProvider, setLocationProvider, getSelectedLocationProviderName
|
|
|
5
5
|
export { getForegroundPermissions, requestForegroundPermissions, getBackgroundPermissions, requestBackgroundPermissions, getNotificationPermissions, requestNotificationPermissions, useForegroundLocationPermissions, useBackgroundLocationPermissions, useNotificationPermissions } from './Permissions';
|
|
6
6
|
export { LocationUpdatesHandle, defineLocationTask } from './LocationUpdatesHandle';
|
|
7
7
|
export { ensureBackgroundSessionStarted, stopBackgroundSession, getBackgroundSessionStatus } from './BackgroundSession';
|
|
8
|
+
export { geocode, reverseGeocode } from './geocoding';
|
|
8
9
|
|
|
9
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["next/js/index.ts"],"sourcesContent":[null],"names":["getPosition","hasLocationServicesEnabled","enableLocationServices","useLocationServices","PositionWatchHandle","watchPosition","LocationProvider","setLocationProvider","getSelectedLocationProviderName","getForegroundPermissions","requestForegroundPermissions","getBackgroundPermissions","requestBackgroundPermissions","getNotificationPermissions","requestNotificationPermissions","useForegroundLocationPermissions","useBackgroundLocationPermissions","useNotificationPermissions","LocationUpdatesHandle","defineLocationTask","ensureBackgroundSessionStarted","stopBackgroundSession","getBackgroundSessionStatus"],"mappings":"AAAA,SAASA,WAAW,QAAQ,gBAAgB;AAC5C,SACEC,0BAA0B,EAC1BC,sBAAsB,EACtBC,mBAAmB,QACd,qBAAqB;AAC5B,SAASC,mBAAmB,EAAEC,aAAa,QAAQ,wBAAwB;AAC3E,SACEC,gBAAgB,EAChBC,mBAAmB,EACnBC,+BAA+B,QAC1B,qBAAqB;AAC5B,SACEC,wBAAwB,EACxBC,4BAA4B,EAC5BC,wBAAwB,EACxBC,4BAA4B,EAC5BC,0BAA0B,EAC1BC,8BAA8B,EAC9BC,gCAAgC,EAChCC,gCAAgC,EAChCC,0BAA0B,QACrB,gBAAgB;AACvB,SAASC,qBAAqB,EAAEC,kBAAkB,QAAQ,0BAA0B;AACpF,SACEC,8BAA8B,EAC9BC,qBAAqB,EACrBC,0BAA0B,QACrB,sBAAsB"}
|
|
1
|
+
{"version":3,"sources":["next/js/index.ts"],"sourcesContent":[null],"names":["getPosition","hasLocationServicesEnabled","enableLocationServices","useLocationServices","PositionWatchHandle","watchPosition","LocationProvider","setLocationProvider","getSelectedLocationProviderName","getForegroundPermissions","requestForegroundPermissions","getBackgroundPermissions","requestBackgroundPermissions","getNotificationPermissions","requestNotificationPermissions","useForegroundLocationPermissions","useBackgroundLocationPermissions","useNotificationPermissions","LocationUpdatesHandle","defineLocationTask","ensureBackgroundSessionStarted","stopBackgroundSession","getBackgroundSessionStatus","geocode","reverseGeocode"],"mappings":"AAAA,SAASA,WAAW,QAAQ,gBAAgB;AAC5C,SACEC,0BAA0B,EAC1BC,sBAAsB,EACtBC,mBAAmB,QACd,qBAAqB;AAC5B,SAASC,mBAAmB,EAAEC,aAAa,QAAQ,wBAAwB;AAC3E,SACEC,gBAAgB,EAChBC,mBAAmB,EACnBC,+BAA+B,QAC1B,qBAAqB;AAC5B,SACEC,wBAAwB,EACxBC,4BAA4B,EAC5BC,wBAAwB,EACxBC,4BAA4B,EAC5BC,0BAA0B,EAC1BC,8BAA8B,EAC9BC,gCAAgC,EAChCC,gCAAgC,EAChCC,0BAA0B,QACrB,gBAAgB;AACvB,SAASC,qBAAqB,EAAEC,kBAAkB,QAAQ,0BAA0B;AACpF,SACEC,8BAA8B,EAC9BC,qBAAqB,EACrBC,0BAA0B,QACrB,sBAAsB;AAC7B,SAASC,OAAO,EAAEC,cAAc,QAAQ,cAAc"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NativeModule } from 'expo';
|
|
2
2
|
import type { PermissionResponse, SharedRef } from 'expo';
|
|
3
|
-
import type { GetPositionOptions, LocationPermissionResponse, LocationProfile, LocationProviderRefType, Position, RequestPermissionsOptions } from '../../types';
|
|
3
|
+
import type { Address, Coordinates, GeocodeOptions, GetPositionOptions, LocationPermissionResponse, LocationProfile, LocationProviderRefType, Position, RequestPermissionsOptions, ReverseGeocodeOptions } from '../../types';
|
|
4
4
|
import type { NativeBackgroundSessionClass } from './NativeBackgroundSessionClass.types';
|
|
5
5
|
import type { NativeLocationProviderClass } from './NativeLocationProviderClass.types';
|
|
6
6
|
import type { NativeLocationUpdatesHandleClass } from './NativeLocationUpdatesHandleClass.types';
|
|
@@ -18,6 +18,8 @@ export declare class NativeLocationModuleNextClass extends NativeModule {
|
|
|
18
18
|
enableLocationServices(): Promise<boolean>;
|
|
19
19
|
getPosition(options?: GetPositionOptions): Promise<Position | null>;
|
|
20
20
|
watchPosition(profile?: LocationProfile): NativePositionWatchHandleClass;
|
|
21
|
+
geocode(address: string, options?: GeocodeOptions): Promise<Address[]>;
|
|
22
|
+
reverseGeocode(coordinates: Coordinates, options?: ReverseGeocodeOptions): Promise<Address[]>;
|
|
21
23
|
LocationProvider: typeof NativeLocationProviderClass;
|
|
22
24
|
PositionWatchHandle: typeof NativePositionWatchHandleClass;
|
|
23
25
|
LocationUpdatesHandle: typeof NativeLocationUpdatesHandleClass;
|