summaryrefslogtreecommitdiff
path: root/platform/ios
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-03-22 10:52:10 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-03-22 10:52:10 -0700
commitb57f0fb987cde24643d5913bbcea83e3aa5ae04d (patch)
treef5f159a5bcfac7b2c38becd897debd1bf72e4748 /platform/ios
parentbbe13b8cc684ee41675d22c0a0c5a08dae9f88ee (diff)
downloadqtlocation-mapboxgl-b57f0fb987cde24643d5913bbcea83e3aa5ae04d.tar.gz
[ios] Fix up center coordinate after lopsided pinch gesture
The gesture recognizer only reports the gesture’s current center point, so use the previous center point to anchor the transition. Fixes #4315.
Diffstat (limited to 'platform/ios')
-rw-r--r--platform/ios/src/MGLMapView.mm18
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