summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Guerra <fabian.guerra@mapbox.com>2019-08-22 17:08:15 -0700
committerFabian Guerra <fabian.guerra@mapbox.com>2019-08-22 17:08:15 -0700
commit2ebc6039f5f8129d73351fe16d754c5ad1ebf8d8 (patch)
tree28b14381dba17970144ac7aecb394fdee20f8c7d
parentfe3460d64a4b698ecd24be8600b7d975791762e9 (diff)
downloadqtlocation-mapboxgl-2ebc6039f5f8129d73351fe16d754c5ad1ebf8d8.tar.gz
[ios] Addresses review feedback.
-rw-r--r--platform/ios/CHANGELOG.md2
-rw-r--r--platform/ios/src/MGLMapView.mm28
2 files changed, 16 insertions, 14 deletions
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md
index abcc768171..5dc73de6d3 100644
--- a/platform/ios/CHANGELOG.md
+++ b/platform/ios/CHANGELOG.md
@@ -4,7 +4,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
## master
-* Fixed an issue that caused tilt gesture to trigger easily. ([#15349](https://github.com/mapbox/mapbox-gl-native/pull/15349))
+* Fixed an issue that caused the tilt gesture to trigger too easily and conflict with pinch or pan gestures. ([#15349](https://github.com/mapbox/mapbox-gl-native/pull/15349))
## 5.3.0
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 821af62ece..86017c9fbd 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -157,6 +157,9 @@ static const NSUInteger MGLPresentsWithTransactionAnnotationCount = 0;
/// An indication that the requested annotation was not found or is nonexistent.
enum { MGLAnnotationTagNotFound = UINT32_MAX };
+/// The threshold used to consider when a tilt gesture should start.
+const CLLocationDegrees MGLHorizontalTiltToleranceDegrees = 45.0;
+
/// Mapping from an annotation tag to metadata about that annotation, including
/// the annotation itself.
typedef std::unordered_map<MGLAnnotationTag, MGLAnnotationContext> MGLAnnotationTagContextMap;
@@ -2157,17 +2160,17 @@ public:
return;
}
- CGPoint west = [twoFingerDrag locationOfTouch:0 inView:twoFingerDrag.view];
- CGPoint east = [twoFingerDrag locationOfTouch:1 inView:twoFingerDrag.view];
- CLLocationDegrees fingerSlopeAngle = [self angleBetweenPoints:west endPoint:east];
+ CGPoint leftTouchPoint = [twoFingerDrag locationOfTouch:0 inView:twoFingerDrag.view];
+ CGPoint rightTouchPoint = [twoFingerDrag locationOfTouch:1 inView:twoFingerDrag.view];
+ CLLocationDegrees fingerSlopeAngle = [self angleBetweenPoints:leftTouchPoint endPoint:rightTouchPoint];
CGPoint middlePoint = [twoFingerDrag translationInView:twoFingerDrag.view];
CLLocationDegrees gestureSlopeAngle = [self angleBetweenPoints:self.dragGestureMiddlePoint endPoint:middlePoint];
self.dragGestureMiddlePoint = middlePoint;
- if (fabs(fingerSlopeAngle) < 45 && fabs(gestureSlopeAngle) > 60 ) {
+ if (fabs(fingerSlopeAngle) < MGLHorizontalTiltToleranceDegrees && fabs(gestureSlopeAngle) > 60.0 ) {
- CGFloat gestureDistance = CGPoint([twoFingerDrag translationInView:twoFingerDrag.view]).y;
+ CGFloat gestureDistance = middlePoint.y;
CGFloat slowdown = 2.0;
CGFloat pitchNew = initialPitch - (gestureDistance / slowdown);
@@ -2323,12 +2326,11 @@ public:
if (panGesture.minimumNumberOfTouches == 2)
{
- CGPoint west = [panGesture locationOfTouch:0 inView:panGesture.view];
- CGPoint east = [panGesture locationOfTouch:1 inView:panGesture.view];
+ CGPoint leftTouchPoint = [panGesture locationOfTouch:0 inView:panGesture.view];
+ CGPoint rightTouchPoint = [panGesture locationOfTouch:1 inView:panGesture.view];
- CLLocationDegrees horizontalToleranceDegrees = 45.0;
- CLLocationDegrees degrees = [self angleBetweenPoints:west endPoint:east];
- if (fabs(degrees) > horizontalToleranceDegrees) {
+ CLLocationDegrees degrees = [self angleBetweenPoints:leftTouchPoint endPoint:rightTouchPoint];
+ if (fabs(degrees) > MGLHorizontalTiltToleranceDegrees) {
return NO;
}
}
@@ -2364,10 +2366,10 @@ public:
CGFloat x = (endPoint.x - originPoint.x);
CGFloat y = (endPoint.y - originPoint.y);
- CGFloat radians = atan2(y, x);
- CLLocationDegrees degrees = MGLDegreesFromRadians(radians);
+ CGFloat angleInRadians = atan2(y, x);
+ CLLocationDegrees angleInDegrees = MGLDegreesFromRadians(angleInRadians);
- return degrees;
+ return angleInDegrees;
}
#pragma mark - Attribution -