diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-11 13:30:03 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-13 10:28:44 -0700 |
commit | f1c06f8d837b57c1b10677fb5317f0bf20987cf6 (patch) | |
tree | fe64a8ca383b76318f0ee10c778460f5a879b3ad /platform/ios/src | |
parent | a2670336d4387782bb607092f3a06814bdf4eb8d (diff) | |
download | qtlocation-mapboxgl-f1c06f8d837b57c1b10677fb5317f0bf20987cf6.tar.gz |
[all] Remove redundant scale-related camera methods
We don't need to have two different measurement systems for map zoom.
Diffstat (limited to 'platform/ios/src')
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index b4c9e9d2a7..5ae588d619 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -1264,7 +1264,7 @@ public: { [self trackGestureEvent:MGLEventGesturePinchStart forRecognizer:pinch]; - self.scale = _mbglMap->getScale(); + self.scale = powf(2, _mbglMap->getZoom()); [self notifyGestureDidBegin]; } @@ -1280,7 +1280,7 @@ public: if (![self.delegate respondsToSelector:@selector(mapView:shouldChangeFromCamera:toCamera:)] || [self.delegate mapView:self shouldChangeFromCamera:oldCamera toCamera:toCamera]) { - _mbglMap->setScale(newScale, mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }); + _mbglMap->setZoom(zoom, mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }); } // The gesture recognizer only reports the gesture’s current center // point, so use the previous center point to anchor the transition. @@ -1338,7 +1338,7 @@ public: } else { if (drift) { - _mbglMap->setScale(newScale, mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }, MGLDurationFromTimeInterval(duration)); + _mbglMap->setZoom(zoom, mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }, MGLDurationFromTimeInterval(duration)); } } @@ -1616,7 +1616,7 @@ public: { [self trackGestureEvent:MGLEventGestureQuickZoom forRecognizer:quickZoom]; - self.scale = _mbglMap->getScale(); + self.scale = powf(2, _mbglMap->getZoom()); self.quickZoomStart = [quickZoom locationInView:quickZoom.view].y; @@ -1633,18 +1633,12 @@ public: CGPoint centerPoint = [self anchorPointForGesture:quickZoom]; MGLMapCamera *oldCamera = self.camera; - - double zoom = self.zoomLevel; - double scale = powf(2, newZoom) / _mbglMap->getScale(); - - double estimatedZoom = zoom * scale; - - MGLMapCamera *toCamera = [self cameraByZoomingToZoomLevel:estimatedZoom aroundAnchorPoint:centerPoint]; + MGLMapCamera *toCamera = [self cameraByZoomingToZoomLevel:newZoom aroundAnchorPoint:centerPoint]; if (![self.delegate respondsToSelector:@selector(mapView:shouldChangeFromCamera:toCamera:)] || [self.delegate mapView:self shouldChangeFromCamera:oldCamera toCamera:toCamera]) { - _mbglMap->scaleBy(scale, mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }); + _mbglMap->setZoom(newZoom, mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }); } [self cameraIsChanging]; @@ -2407,7 +2401,7 @@ public: { centerPoint = self.userLocationAnnotationViewCenter; } - _mbglMap->scaleBy(scaleFactor, mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }); + _mbglMap->setZoom(_mbglMap->getZoom() + log2(scaleFactor), mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }); [self unrotateIfNeededForGesture]; UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, self.accessibilityValue); |