diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2019-02-27 19:01:29 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2019-03-04 14:45:32 +0200 |
commit | f5f10ec11989ccb403c2cd4261db74c44b263558 (patch) | |
tree | 8c88ee24819281609206e36c719eef617acb52b6 /platform/macos/src/MGLMapView.mm | |
parent | 491fce68790e05cd0a876815751dc5cb72a2761e (diff) | |
download | qtlocation-mapboxgl-f5f10ec11989ccb403c2cd4261db74c44b263558.tar.gz |
[core] Remove map zoom setters/getters
Diffstat (limited to 'platform/macos/src/MGLMapView.mm')
-rw-r--r-- | platform/macos/src/MGLMapView.mm | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 5a24524b4a..03088ac5c6 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -1047,7 +1047,8 @@ public: } - (double)zoomLevel { - return _mbglMap->getZoom(); + mbgl::EdgeInsets padding = MGLEdgeInsetsFromNSEdgeInsets(self.contentInsets); + return *_mbglMap->getCameraOptions(padding).zoom; } - (void)setZoomLevel:(double)zoomLevel { @@ -1058,9 +1059,10 @@ public: - (void)setZoomLevel:(double)zoomLevel animated:(BOOL)animated { MGLLogDebug(@"Setting zoomLevel: %f animated: %@", zoomLevel, MGLStringFromBOOL(animated)); [self willChangeValueForKey:@"zoomLevel"]; - _mbglMap->setZoom(zoomLevel, - MGLEdgeInsetsFromNSEdgeInsets(self.contentInsets), - MGLDurationFromTimeInterval(animated ? MGLAnimationDuration : 0)); + _mbglMap->easeTo(mbgl::CameraOptions() + .withZoom(zoomLevel) + .withPadding(MGLEdgeInsetsFromNSEdgeInsets(self.contentInsets)), + MGLDurationFromTimeInterval(animated ? MGLAnimationDuration : 0)); [self didChangeValueForKey:@"zoomLevel"]; } @@ -1069,7 +1071,10 @@ public: [self willChangeValueForKey:@"zoomLevel"]; MGLMapCamera *oldCamera = self.camera; mbgl::ScreenCoordinate center(point.x, self.bounds.size.height - point.y); - _mbglMap->setZoom(zoomLevel, center, MGLDurationFromTimeInterval(animated ? MGLAnimationDuration : 0)); + _mbglMap->easeTo(mbgl::CameraOptions() + .withZoom(zoomLevel) + .withAnchor(center), + MGLDurationFromTimeInterval(animated ? MGLAnimationDuration : 0)); if ([self.delegate respondsToSelector:@selector(mapView:shouldChangeFromCamera:toCamera:)] && ![self.delegate mapView:self shouldChangeFromCamera:oldCamera toCamera:self.camera]) { self.camera = oldCamera; @@ -1461,7 +1466,7 @@ public: _mbglMap->cancelTransitions(); if (gestureRecognizer.state == NSGestureRecognizerStateBegan) { - _zoomAtBeginningOfGesture = _mbglMap->getZoom(); + _zoomAtBeginningOfGesture = [self zoomLevel]; } else if (gestureRecognizer.state == NSGestureRecognizerStateChanged) { CGFloat newZoomLevel = _zoomAtBeginningOfGesture - delta.y / 75; [self setZoomLevel:newZoomLevel atPoint:startPoint animated:NO]; @@ -1525,7 +1530,7 @@ public: if (gestureRecognizer.state == NSGestureRecognizerStateBegan) { _mbglMap->setGestureInProgress(true); - _zoomAtBeginningOfGesture = _mbglMap->getZoom(); + _zoomAtBeginningOfGesture = [self zoomLevel]; } else if (gestureRecognizer.state == NSGestureRecognizerStateChanged) { NSPoint zoomInPoint = [gestureRecognizer locationInView:self]; mbgl::ScreenCoordinate center(zoomInPoint.x, self.bounds.size.height - zoomInPoint.y); @@ -1533,7 +1538,9 @@ public: [self willChangeValueForKey:@"zoomLevel"]; [self willChangeValueForKey:@"centerCoordinate"]; MGLMapCamera *oldCamera = self.camera; - _mbglMap->setZoom(_zoomAtBeginningOfGesture + log2(1 + gestureRecognizer.magnification), center); + _mbglMap->jumpTo(mbgl::CameraOptions() + .withZoom(_zoomAtBeginningOfGesture + log2(1 + gestureRecognizer.magnification)) + .withAnchor(center)); if ([self.delegate respondsToSelector:@selector(mapView:shouldChangeFromCamera:toCamera:)] && ![self.delegate mapView:self shouldChangeFromCamera:oldCamera toCamera:self.camera]) { self.camera = oldCamera; |