Skip to content

Commit ab2f409

Browse files
authored
Merge pull request #15 from zgosalvez/hotfix/my-location-with-always-authorization
Adds support for my location with always authorized status.
2 parents e1cdb7a + 011b593 commit ab2f409

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

ios/Classes/MapView/FlutterMapView.swift

+13-2
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,25 @@ class FlutterMapView: MKMapView, UIGestureRecognizerDelegate {
196196
}
197197

198198
public func setUserLocation() {
199-
if CLLocationManager.authorizationStatus() == .notDetermined {
199+
let authorizationStatus = CLLocationManager.authorizationStatus()
200+
201+
switch authorizationStatus {
202+
case .notDetermined:
200203
locationManager.requestWhenInUseAuthorization()
201-
} else if CLLocationManager.authorizationStatus() == .authorizedWhenInUse {
204+
break
205+
206+
case .authorizedAlways:
207+
fallthrough
208+
case .authorizedWhenInUse:
202209
locationManager.requestWhenInUseAuthorization()
203210
locationManager.desiredAccuracy = kCLLocationAccuracyBest
204211
locationManager.distanceFilter = kCLDistanceFilterNone
205212
locationManager.startUpdatingLocation()
206213
self.showsUserLocation = true
214+
break
215+
216+
default:
217+
print("\(authorizationStatus.rawValue) is not supported.")
207218
}
208219
}
209220

0 commit comments

Comments
 (0)