diff options
Diffstat (limited to 'platform/ios/src/MGLMapView.mm')
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index adfb635312..1d7a5090d5 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -211,6 +211,10 @@ public: NSUInteger _changeDelimiterSuppressionDepth; + /// Center coordinate of the pinch gesture on the previous iteration of the gesture. + CLLocationCoordinate2D _previousPinchCenterCoordinate; + NSUInteger _previousPinchNumberOfTouches; + BOOL _delegateHasAlphasForShapeAnnotations; BOOL _delegateHasStrokeColorsForShapeAnnotations; BOOL _delegateHasFillColorsForShapeAnnotations; @@ -1133,6 +1137,17 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) if (log2(newScale) < _mbglMap->getMinZoom()) return; _mbglMap->setScale(newScale, { 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. + // If the number of touches has changed, the remembered center point is + // meaningless. + if (self.userTrackingMode == MGLUserTrackingModeNone && pinch.numberOfTouches == _previousPinchNumberOfTouches) + { + CLLocationCoordinate2D centerCoordinate = _previousPinchCenterCoordinate; + _mbglMap->setLatLng(MGLLatLngFromLocationCoordinate2D(centerCoordinate), + { centerPoint.x, centerPoint.y }); + } [self notifyMapChange:mbgl::MapChangeRegionIsChanging]; } @@ -1176,6 +1191,9 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) [self unrotateIfNeededForGesture]; } + + _previousPinchCenterCoordinate = [self convertPoint:[pinch locationInView:pinch.view] toCoordinateFromView:self]; + _previousPinchNumberOfTouches = pinch.numberOfTouches; } - (void)handleRotateGesture:(UIRotationGestureRecognizer *)rotate |