react-native-google-maps-plus 1.10.0-dev.3 → 1.10.0-dev.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -152,6 +152,7 @@ class GoogleMapsViewImpl(
|
|
|
152
152
|
super.addView(it)
|
|
153
153
|
it.getMapAsync { map ->
|
|
154
154
|
googleMap = map
|
|
155
|
+
googleMap?.setLocationSource(locationHandler)
|
|
155
156
|
googleMap?.setOnMapLoadedCallback {
|
|
156
157
|
googleMap?.setOnCameraMoveStartedListener(this@GoogleMapsViewImpl)
|
|
157
158
|
googleMap?.setOnCameraMoveListener(this@GoogleMapsViewImpl)
|
|
@@ -288,11 +289,7 @@ class GoogleMapsViewImpl(
|
|
|
288
289
|
isCompassEnabled = value?.compassEnabled ?: false
|
|
289
290
|
isIndoorLevelPickerEnabled = value?.indoorLevelPickerEnabled ?: false
|
|
290
291
|
isMapToolbarEnabled = value?.mapToolbarEnabled ?: false
|
|
291
|
-
|
|
292
|
-
val myLocationEnabled = value?.myLocationButtonEnabled ?: false
|
|
293
|
-
googleMap?.setLocationSource(if (myLocationEnabled) locationHandler else null)
|
|
294
|
-
isMyLocationButtonEnabled = myLocationEnabled
|
|
295
|
-
|
|
292
|
+
isMyLocationButtonEnabled = value?.myLocationButtonEnabled ?: false
|
|
296
293
|
isRotateGesturesEnabled = value?.rotateEnabled ?: true
|
|
297
294
|
isScrollGesturesEnabled = value?.scrollEnabled ?: true
|
|
298
295
|
isScrollGesturesEnabledDuringRotateOrZoom =
|
|
@@ -19,7 +19,6 @@ import com.google.android.gms.location.LocationServices
|
|
|
19
19
|
import com.google.android.gms.location.LocationSettingsRequest
|
|
20
20
|
import com.google.android.gms.location.Priority
|
|
21
21
|
import com.google.android.gms.maps.LocationSource
|
|
22
|
-
import com.google.android.gms.tasks.OnSuccessListener
|
|
23
22
|
import com.rngooglemapsplus.extensions.toLocationErrorCode
|
|
24
23
|
|
|
25
24
|
private const val REQ_LOCATION_SETTINGS = 2001
|
|
@@ -144,13 +143,12 @@ class LocationHandler(
|
|
|
144
143
|
}
|
|
145
144
|
try {
|
|
146
145
|
fusedLocationClientProviderClient.lastLocation
|
|
147
|
-
.addOnSuccessListener
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
).addOnFailureListener { e ->
|
|
146
|
+
.addOnSuccessListener { location ->
|
|
147
|
+
if (location != null) {
|
|
148
|
+
listener?.onLocationChanged(location)
|
|
149
|
+
onUpdate?.invoke(location)
|
|
150
|
+
}
|
|
151
|
+
}.addOnFailureListener { e ->
|
|
154
152
|
val error = e.toLocationErrorCode(context)
|
|
155
153
|
onError?.invoke(error)
|
|
156
154
|
}
|
|
@@ -166,14 +164,14 @@ class LocationHandler(
|
|
|
166
164
|
}
|
|
167
165
|
}
|
|
168
166
|
}
|
|
167
|
+
|
|
168
|
+
val req = locationRequest ?: return
|
|
169
|
+
val callback = locationCallback ?: return
|
|
170
|
+
|
|
169
171
|
fusedLocationClientProviderClient
|
|
170
|
-
.requestLocationUpdates(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
Looper.getMainLooper(),
|
|
174
|
-
).addOnFailureListener { e ->
|
|
175
|
-
val error = e.toLocationErrorCode(context)
|
|
176
|
-
onError?.invoke(error)
|
|
172
|
+
.requestLocationUpdates(req, callback, Looper.getMainLooper())
|
|
173
|
+
.addOnFailureListener { e ->
|
|
174
|
+
onError?.invoke(e.toLocationErrorCode(context))
|
|
177
175
|
}
|
|
178
176
|
} catch (_: SecurityException) {
|
|
179
177
|
onError?.invoke(RNLocationErrorCode.PERMISSION_DENIED)
|
|
@@ -186,11 +184,10 @@ class LocationHandler(
|
|
|
186
184
|
fun stop() {
|
|
187
185
|
if (!isActive) return
|
|
188
186
|
isActive = false
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
187
|
+
val callback = locationCallback ?: return
|
|
188
|
+
fusedLocationClientProviderClient.removeLocationUpdates(callback)
|
|
189
|
+
fusedLocationClientProviderClient.flushLocations()
|
|
190
|
+
locationCallback = null
|
|
194
191
|
}
|
|
195
192
|
|
|
196
193
|
override fun activate(listener: LocationSource.OnLocationChangedListener) {
|
package/package.json
CHANGED