[ios, osx] Constrain zoom level when selecting offline pack
When selecting an offline pack for display in iosapp or osxapp, constrain the zoom level to the pack’s minimum and maximum zoom levels. Fixes #4787.
This commit is contained in:
committed by
Minh Nguyễn
parent
0dbec51401
commit
3a22033b90
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user