diff options
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 89 |
1 files changed, 42 insertions, 47 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index c48a161496..7003f2e4b4 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -1585,10 +1585,7 @@ public: - (void)handleSingleTapGesture:(UITapGestureRecognizer *)singleTap { - if (singleTap.state != UIGestureRecognizerStateRecognized) - { - return; - } + if (singleTap.state != UIGestureRecognizerStateRecognized) return; [self trackGestureEvent:MMEEventGestureSingleTap forRecognizer:singleTap]; @@ -1694,45 +1691,46 @@ public: - (void)handleDoubleTapGesture:(UITapGestureRecognizer *)doubleTap { + if (doubleTap.state != UIGestureRecognizerStateRecognized) return; + if ( ! self.isZoomEnabled) return; [self cancelTransitions]; self.cameraChangeReasonBitmask |= MGLCameraChangeReasonGestureZoomIn; - if (doubleTap.state == UIGestureRecognizerStateRecognized) - { - MGLMapCamera *oldCamera = self.camera; + MGLMapCamera *oldCamera = self.camera; - double newZoom = round(self.zoomLevel) + 1.0; + double newZoom = round(self.zoomLevel) + 1.0; - CGPoint gesturePoint = [self anchorPointForGesture:doubleTap]; + CGPoint gesturePoint = [self anchorPointForGesture:doubleTap]; - MGLMapCamera *toCamera = [self cameraByZoomingToZoomLevel:newZoom aroundAnchorPoint:gesturePoint]; + MGLMapCamera *toCamera = [self cameraByZoomingToZoomLevel:newZoom aroundAnchorPoint:gesturePoint]; - if ([self _shouldChangeFromCamera:oldCamera toCamera:toCamera]) - { - [self trackGestureEvent:MMEEventGestureDoubleTap forRecognizer:doubleTap]; - - mbgl::ScreenCoordinate center(gesturePoint.x, gesturePoint.y); - _mbglMap->setZoom(newZoom, center, MGLDurationFromTimeInterval(MGLAnimationDuration)); - - __weak MGLMapView *weakSelf = self; - - [self animateWithDelay:MGLAnimationDuration animations:^ - { - [weakSelf unrotateIfNeededForGesture]; - }]; - } - else - { - [self unrotateIfNeededForGesture]; - } + if ([self _shouldChangeFromCamera:oldCamera toCamera:toCamera]) + { + [self trackGestureEvent:MMEEventGestureDoubleTap forRecognizer:doubleTap]; + + mbgl::ScreenCoordinate center(gesturePoint.x, gesturePoint.y); + _mbglMap->setZoom(newZoom, center, MGLDurationFromTimeInterval(MGLAnimationDuration)); + + __weak MGLMapView *weakSelf = self; + + [self animateWithDelay:MGLAnimationDuration animations:^ + { + [weakSelf unrotateIfNeededForGesture]; + }]; + } + else + { + [self unrotateIfNeededForGesture]; } } - (void)handleTwoFingerTapGesture:(UITapGestureRecognizer *)twoFingerTap { + if (twoFingerTap.state != UIGestureRecognizerStateRecognized) return; + if ( ! self.isZoomEnabled) return; if (_mbglMap->getZoom() == _mbglMap->getMinZoom()) return; @@ -1741,30 +1739,27 @@ public: self.cameraChangeReasonBitmask |= MGLCameraChangeReasonGestureZoomOut; - if (twoFingerTap.state == UIGestureRecognizerStateRecognized) - { - MGLMapCamera *oldCamera = self.camera; + MGLMapCamera *oldCamera = self.camera; - double newZoom = round(self.zoomLevel) - 1.0; + double newZoom = round(self.zoomLevel) - 1.0; - CGPoint gesturePoint = [self anchorPointForGesture:twoFingerTap]; + CGPoint gesturePoint = [self anchorPointForGesture:twoFingerTap]; - MGLMapCamera *toCamera = [self cameraByZoomingToZoomLevel:newZoom aroundAnchorPoint:gesturePoint]; + MGLMapCamera *toCamera = [self cameraByZoomingToZoomLevel:newZoom aroundAnchorPoint:gesturePoint]; - if ([self _shouldChangeFromCamera:oldCamera toCamera:toCamera]) - { - [self trackGestureEvent:MMEEventGestureTwoFingerSingleTap forRecognizer:twoFingerTap]; + if ([self _shouldChangeFromCamera:oldCamera toCamera:toCamera]) + { + [self trackGestureEvent:MMEEventGestureTwoFingerSingleTap forRecognizer:twoFingerTap]; - mbgl::ScreenCoordinate center(gesturePoint.x, gesturePoint.y); - _mbglMap->setZoom(newZoom, center, MGLDurationFromTimeInterval(MGLAnimationDuration)); - - __weak MGLMapView *weakSelf = self; - - [self animateWithDelay:MGLAnimationDuration animations:^ - { - [weakSelf unrotateIfNeededForGesture]; - }]; - } + mbgl::ScreenCoordinate center(gesturePoint.x, gesturePoint.y); + _mbglMap->setZoom(newZoom, center, MGLDurationFromTimeInterval(MGLAnimationDuration)); + + __weak MGLMapView *weakSelf = self; + + [self animateWithDelay:MGLAnimationDuration animations:^ + { + [weakSelf unrotateIfNeededForGesture]; + }]; } } |