diff --git a/platform/ios/app/MBXOfflinePacksTableViewController.m b/platform/ios/app/MBXOfflinePacksTableViewController.m index 8aad4fbbf..9b1a12a93 100644 --- a/platform/ios/app/MBXOfflinePacksTableViewController.m +++ b/platform/ios/app/MBXOfflinePacksTableViewController.m @@ -24,6 +24,7 @@ static NSString * const MBXOfflinePacksTableViewActiveCellReuseIdentifier = @"Ac - (void)applyToMapView:(MGLMapView *)mapView { mapView.styleURL = self.styleURL; [mapView setVisibleCoordinateBounds:self.bounds]; + mapView.zoomLevel = MIN(self.maximumZoomLevel, MAX(self.minimumZoomLevel, mapView.zoomLevel)); } @end diff --git a/platform/osx/app/AppDelegate.h b/platform/osx/app/AppDelegate.h index ca9edab77..a1d9297b2 100644 --- a/platform/osx/app/AppDelegate.h +++ b/platform/osx/app/AppDelegate.h @@ -16,6 +16,8 @@ extern NSString * const MGLMapboxAccessTokenDefaultsKey; @property (assign) double pendingZoomLevel; @property (copy) MGLMapCamera *pendingCamera; @property (assign) MGLCoordinateBounds pendingVisibleCoordinateBounds; +@property (assign) double pendingMinimumZoomLevel; +@property (assign) double pendingMaximumZoomLevel; @property (copy) NSURL *pendingStyleURL; @property (assign) MGLMapDebugMaskOptions pendingDebugMask; diff --git a/platform/osx/app/AppDelegate.m b/platform/osx/app/AppDelegate.m index d9fd96741..b7860cf13 100644 --- a/platform/osx/app/AppDelegate.m +++ b/platform/osx/app/AppDelegate.m @@ -204,6 +204,8 @@ NSString * const MGLLastMapDebugMaskDefaultsKey = @"MGLLastMapDebugMask"; if ([pack.region isKindOfClass:[MGLTilePyramidOfflineRegion class]]) { MGLTilePyramidOfflineRegion *region = (MGLTilePyramidOfflineRegion *)pack.region; self.pendingVisibleCoordinateBounds = region.bounds; + self.pendingMinimumZoomLevel = region.minimumZoomLevel; + self.pendingMaximumZoomLevel = region.maximumZoomLevel; [[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:NULL]; } break; diff --git a/platform/osx/app/MapDocument.m b/platform/osx/app/MapDocument.m index 2c5930f00..256bd5b6e 100644 --- a/platform/osx/app/MapDocument.m +++ b/platform/osx/app/MapDocument.m @@ -211,6 +211,12 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { if (appDelegate.pendingDebugMask) { self.mapView.debugMask = appDelegate.pendingDebugMask; } + if (appDelegate.pendingMinimumZoomLevel >= 0) { + self.mapView.zoomLevel = MAX(appDelegate.pendingMinimumZoomLevel, self.mapView.zoomLevel); + } + if (appDelegate.pendingMaximumZoomLevel >= 0) { + self.mapView.zoomLevel = MIN(appDelegate.pendingMaximumZoomLevel, self.mapView.zoomLevel); + } // Temporarily set the display name to the default center coordinate instead // of “Untitled” until the binding kicks in.