react-native-google-maps-plus 1.10.0-dev.5 → 1.10.0-dev.6

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.
@@ -34,10 +34,12 @@ class LocationHandler(
34
34
  private var listener: LocationSource.OnLocationChangedListener? = null
35
35
  private var locationRequest: LocationRequest? = null
36
36
  private var locationCallback: LocationCallback? = null
37
+ private var lastLocation: Location? = null
38
+ private var isActive = false
39
+
37
40
  private var priority: Int = PRIORITY_DEFAULT
38
41
  private var interval: Long = INTERVAL_DEFAULT
39
42
  private var minUpdateInterval: Long = MIN_UPDATE_INTERVAL
40
- private var isActive = false
41
43
 
42
44
  var onUpdate: ((Location) -> Unit)? = null
43
45
  var onError: ((RNLocationErrorCode) -> Unit)? = null
@@ -142,21 +144,23 @@ class LocationHandler(
142
144
  return
143
145
  }
144
146
  try {
145
- fusedLocationClientProviderClient.lastLocation
147
+ fusedLocationClientProviderClient
148
+ .getCurrentLocation(Priority.PRIORITY_HIGH_ACCURACY, null)
146
149
  .addOnSuccessListener { location ->
147
150
  if (location != null) {
151
+ lastLocation = location
148
152
  listener?.onLocationChanged(location)
149
153
  onUpdate?.invoke(location)
150
154
  }
151
155
  }.addOnFailureListener { e ->
152
- val error = e.toLocationErrorCode(context)
153
- onError?.invoke(error)
156
+ onError?.invoke(e.toLocationErrorCode(context))
154
157
  }
155
158
  locationCallback =
156
159
  object : LocationCallback() {
157
160
  override fun onLocationResult(locationResult: LocationResult) {
158
161
  val location = locationResult.lastLocation
159
162
  if (location != null) {
163
+ lastLocation = location
160
164
  listener?.onLocationChanged(location)
161
165
  onUpdate?.invoke(location)
162
166
  } else {
@@ -192,6 +196,9 @@ class LocationHandler(
192
196
 
193
197
  override fun activate(listener: LocationSource.OnLocationChangedListener) {
194
198
  this.listener = listener
199
+ lastLocation?.let {
200
+ listener.onLocationChanged(it)
201
+ }
195
202
  }
196
203
 
197
204
  override fun deactivate() {
@@ -85,10 +85,7 @@ final class LocationHandler: NSObject, CLLocationManagerDelegate {
85
85
  guard !isActive else { return }
86
86
  isActive = true
87
87
 
88
- manager.location.map {
89
- onUpdate?($0)
90
- }
91
-
88
+ manager.requestLocation()
92
89
  manager.startUpdatingLocation()
93
90
  }
94
91
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-google-maps-plus",
3
- "version": "1.10.0-dev.5",
3
+ "version": "1.10.0-dev.6",
4
4
  "description": "React Native wrapper for Android & iOS Google Maps SDK",
5
5
  "main": "./lib/module/index.js",
6
6
  "module": "./lib/module/index.js",