react-native-google-maps-plus 1.10.0-dev.2 → 1.10.0-dev.4
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.
|
@@ -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
|
|
@@ -56,6 +55,8 @@ class LocationHandler(
|
|
|
56
55
|
this.interval = interval ?: INTERVAL_DEFAULT
|
|
57
56
|
this.minUpdateInterval = minUpdateInterval ?: MIN_UPDATE_INTERVAL
|
|
58
57
|
buildLocationRequest(this.priority, this.interval, this.minUpdateInterval)
|
|
58
|
+
|
|
59
|
+
if (!isActive) return
|
|
59
60
|
stop()
|
|
60
61
|
start()
|
|
61
62
|
}
|
|
@@ -142,13 +143,12 @@ class LocationHandler(
|
|
|
142
143
|
}
|
|
143
144
|
try {
|
|
144
145
|
fusedLocationClientProviderClient.lastLocation
|
|
145
|
-
.addOnSuccessListener
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
).addOnFailureListener { e ->
|
|
146
|
+
.addOnSuccessListener { location ->
|
|
147
|
+
if (location != null) {
|
|
148
|
+
listener?.onLocationChanged(location)
|
|
149
|
+
onUpdate?.invoke(location)
|
|
150
|
+
}
|
|
151
|
+
}.addOnFailureListener { e ->
|
|
152
152
|
val error = e.toLocationErrorCode(context)
|
|
153
153
|
onError?.invoke(error)
|
|
154
154
|
}
|
|
@@ -164,16 +164,16 @@ class LocationHandler(
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
+
|
|
168
|
+
val req = locationRequest ?: return
|
|
169
|
+
val callback = locationCallback ?: return
|
|
170
|
+
|
|
167
171
|
fusedLocationClientProviderClient
|
|
168
|
-
.requestLocationUpdates(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
Looper.getMainLooper(),
|
|
172
|
-
).addOnFailureListener { e ->
|
|
173
|
-
val error = e.toLocationErrorCode(context)
|
|
174
|
-
onError?.invoke(error)
|
|
172
|
+
.requestLocationUpdates(req, callback, Looper.getMainLooper())
|
|
173
|
+
.addOnFailureListener { e ->
|
|
174
|
+
onError?.invoke(e.toLocationErrorCode(context))
|
|
175
175
|
}
|
|
176
|
-
} catch (
|
|
176
|
+
} catch (_: SecurityException) {
|
|
177
177
|
onError?.invoke(RNLocationErrorCode.PERMISSION_DENIED)
|
|
178
178
|
} catch (ex: Exception) {
|
|
179
179
|
val error = ex.toLocationErrorCode(context)
|
|
@@ -184,20 +184,17 @@ class LocationHandler(
|
|
|
184
184
|
fun stop() {
|
|
185
185
|
if (!isActive) return
|
|
186
186
|
isActive = false
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
187
|
+
val callback = locationCallback ?: return
|
|
188
|
+
fusedLocationClientProviderClient.removeLocationUpdates(callback)
|
|
189
|
+
fusedLocationClientProviderClient.flushLocations()
|
|
190
|
+
locationCallback = null
|
|
192
191
|
}
|
|
193
192
|
|
|
194
193
|
override fun activate(listener: LocationSource.OnLocationChangedListener) {
|
|
195
194
|
this.listener = listener
|
|
196
|
-
start()
|
|
197
195
|
}
|
|
198
196
|
|
|
199
197
|
override fun deactivate() {
|
|
200
198
|
listener = null
|
|
201
|
-
stop()
|
|
202
199
|
}
|
|
203
200
|
}
|
|
@@ -10,8 +10,8 @@ GMSIndoorDisplayDelegate {
|
|
|
10
10
|
private let locationHandler: LocationHandler
|
|
11
11
|
private let markerBuilder: MapMarkerBuilder
|
|
12
12
|
private var mapView: GMSMapView?
|
|
13
|
-
private var
|
|
14
|
-
private var
|
|
13
|
+
private var mapViewInitialized = false
|
|
14
|
+
private var mapViewLoaded = false
|
|
15
15
|
private var deInitialized = false
|
|
16
16
|
|
|
17
17
|
private var pendingMarkers: [(id: String, marker: GMSMarker)] = []
|
|
@@ -97,8 +97,8 @@ GMSIndoorDisplayDelegate {
|
|
|
97
97
|
|
|
98
98
|
@MainActor
|
|
99
99
|
func initMapView() {
|
|
100
|
-
if
|
|
101
|
-
|
|
100
|
+
if mapViewInitialized { return }
|
|
101
|
+
mapViewInitialized = true
|
|
102
102
|
googleMapOptions.frame = bounds
|
|
103
103
|
|
|
104
104
|
mapView = GMSMapView.init(options: googleMapOptions)
|
|
@@ -221,7 +221,7 @@ GMSIndoorDisplayDelegate {
|
|
|
221
221
|
@MainActor
|
|
222
222
|
var trafficEnabled: Bool? {
|
|
223
223
|
didSet {
|
|
224
|
-
mapView?.isTrafficEnabled = false
|
|
224
|
+
mapView?.isTrafficEnabled = trafficEnabled ?? false
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
|
|
@@ -717,7 +717,6 @@ GMSIndoorDisplayDelegate {
|
|
|
717
717
|
self.mapView?.indoorDisplay.delegate = nil
|
|
718
718
|
self.mapView?.delegate = nil
|
|
719
719
|
self.mapView = nil
|
|
720
|
-
self.initialized = false
|
|
721
720
|
}
|
|
722
721
|
}
|
|
723
722
|
|
|
@@ -752,8 +751,8 @@ GMSIndoorDisplayDelegate {
|
|
|
752
751
|
}
|
|
753
752
|
|
|
754
753
|
func mapViewDidFinishTileRendering(_ mapView: GMSMapView) {
|
|
755
|
-
guard !
|
|
756
|
-
|
|
754
|
+
guard !mapViewLoaded else { return }
|
|
755
|
+
mapViewLoaded = true
|
|
757
756
|
let visibleRegion = mapView.projection.visibleRegion().toRNRegion()
|
|
758
757
|
let camera = mapView.camera.toRNCamera()
|
|
759
758
|
|
|
@@ -761,7 +760,7 @@ GMSIndoorDisplayDelegate {
|
|
|
761
760
|
}
|
|
762
761
|
|
|
763
762
|
func mapView(_ mapView: GMSMapView, willMove gesture: Bool) {
|
|
764
|
-
if !
|
|
763
|
+
if !mapViewLoaded { return }
|
|
765
764
|
onMain {
|
|
766
765
|
self.cameraMoveReasonIsGesture = gesture
|
|
767
766
|
|
|
@@ -773,7 +772,7 @@ GMSIndoorDisplayDelegate {
|
|
|
773
772
|
}
|
|
774
773
|
|
|
775
774
|
func mapView(_ mapView: GMSMapView, didChange position: GMSCameraPosition) {
|
|
776
|
-
if !
|
|
775
|
+
if !mapViewLoaded { return }
|
|
777
776
|
onMain {
|
|
778
777
|
let visibleRegion = mapView.projection.visibleRegion().toRNRegion()
|
|
779
778
|
let camera = mapView.camera.toRNCamera()
|
|
@@ -784,7 +783,7 @@ GMSIndoorDisplayDelegate {
|
|
|
784
783
|
}
|
|
785
784
|
|
|
786
785
|
func mapView(_ mapView: GMSMapView, idleAt position: GMSCameraPosition) {
|
|
787
|
-
if !
|
|
786
|
+
if !mapViewLoaded { return }
|
|
788
787
|
onMain {
|
|
789
788
|
let visibleRegion = mapView.projection.visibleRegion().toRNRegion()
|
|
790
789
|
let camera = mapView.camera.toRNCamera()
|
package/package.json
CHANGED