diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2023-01-17 12:13:51 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2023-01-17 15:27:21 +0100 |
| commit | ec32c5b3d3258b14ad8d2334e025f8fd16962471 (patch) | |
| tree | ff93d73704e70e9c16d5383498a6278a2d923c18 | |
| parent | 76b3ccd8ce4d8295b7b6b7e4ef7ee8b89bc047fc (diff) | |
| download | mullvadvpn-ec32c5b3d3258b14ad8d2334e025f8fd16962471.tar.xz mullvadvpn-ec32c5b3d3258b14ad8d2334e025f8fd16962471.zip | |
Guard against producing wrong region when view width is zero
| -rw-r--r-- | ios/MullvadVPN/MapViewController.swift | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/ios/MullvadVPN/MapViewController.swift b/ios/MullvadVPN/MapViewController.swift index 44ba69a22f..2ea933d9ef 100644 --- a/ios/MullvadVPN/MapViewController.swift +++ b/ios/MullvadVPN/MapViewController.swift @@ -179,6 +179,13 @@ final class MapViewController: UIViewController, MKMapViewDelegate { self.center = center + logger.debug( + """ + Set map region to: (\(region.center.latitude), \(region.center.longitude), \ + \(region.span.latitudeDelta), \(region.span.longitudeDelta)) + """ + ) + // Map view does not call delegate methods when attempting to set the same region. mapView.setRegion(region, animated: animated) @@ -247,6 +254,7 @@ final class MapViewController: UIViewController, MKMapViewDelegate { ) -> MKCoordinateRegion { // Map view center lies within layout margins frame. let mapViewLayoutFrame = mapView.layoutMarginsGuide.layoutFrame + guard mapViewLayoutFrame.width > 0 else { return region } // MKMapView.convert(_:toRectTo:) returns CGRect scaled to the zoom level derived from // currently set region. |
