From 371a210be877e21ad6564f739d1c5f3ef7f3c532 Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Wed, 27 Jan 2016 11:34:12 -0800 Subject: [ios] getters, setters for minZoom, maxZoom adds: minimumZoomLevel setMinimumZoomLevel maximumZoomLevel setMaximumZoomLevel --- CHANGELOG.md | 2 ++ include/mbgl/ios/MGLMapView.h | 24 ++++++++++++++++++++++++ platform/ios/src/MGLMapView.mm | 20 ++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45eedeb6f5..822028f4c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,6 +75,8 @@ Known issues: - Fixed crash caused by MGLAnnotationImage with non-integer width or height ([#2198](https://github.com/mapbox/mapbox-gl-native/issues/2198)) - Fixed “include of non-modular header” errors in Swift projects managed by CocoaPods. ([#3679](https://github.com/mapbox/mapbox-gl-native/pull/3679)) - Avoids triggering the blue background location status bar when user has granted "when in use" permission. ([#3671](https://github.com/mapbox/mapbox-gl-native/issues/3671)) +- Added new methods to MGLMapView for getting and setting the minimum and maximum zoom levels: `minimumZoomLevel`, `setMinimumZoomLevel`, `maximumZoomLevel`, `setMaximumZoomLevel`. ([#509](https://github.com/mapbox/mapbox-gl-native/issues/509)) +- The default `maximumZoomLevel` changed from 18 to 20. ## iOS 3.0.1 diff --git a/include/mbgl/ios/MGLMapView.h b/include/mbgl/ios/MGLMapView.h index b27db4976a..bd4b048d64 100644 --- a/include/mbgl/ios/MGLMapView.h +++ b/include/mbgl/ios/MGLMapView.h @@ -463,6 +463,30 @@ IB_DESIGNABLE */ - (void)setZoomLevel:(double)zoomLevel animated:(BOOL)animated; +/** + * The minimum zoom level at which the map can be shown. + * + * Depending on the map view’s aspect ratio, the map view may be prevented + * from reaching the minimum zoom level, in order to keep the map from + * repeating within the current viewport. + * + * If the value of this property is greater than that of the + * maximumZoomLevel property, the behavior is undefined. + * + * The default minimumZoomLevel is 0. + */ +@property (nonatomic) double minimumZoomLevel; + +/** + * The maximum zoom level the map can be shown at. + * + * If the value of this property is smaller than that of the + * minimumZoomLevel property, the behavior is undefined. + * + * The default maximumZoomLevel is 20. + */ +@property (nonatomic) double maximumZoomLevel; + /** The heading of the map, measured in degrees clockwise from true north. diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index e301686419..954fc8a935 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -1784,6 +1784,26 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) MGLDurationInSeconds(duration)); } +- (void)setMinimumZoomLevel:(double)minimumZoomLevel +{ + _mbglMap->setMinZoom(minimumZoomLevel); +} + +- (double)minimumZoomLevel +{ + return _mbglMap->getMinZoom(); +} + +- (void)setMaximumZoomLevel:(double)maximumZoomLevel +{ + _mbglMap->setMaxZoom(maximumZoomLevel); +} + +- (double)maximumZoomLevel +{ + return _mbglMap->getMaxZoom(); +} + - (MGLCoordinateBounds)visibleCoordinateBounds { return [self convertRect:self.bounds toCoordinateBoundsFromView:self]; -- cgit v1.2.1