diff options
author | David Chiles <david@davidchiles.org> | 2017-03-07 14:14:56 -0800 |
---|---|---|
committer | Jesse Bounds <jesse@rebounds.net> | 2017-04-11 07:33:22 -0700 |
commit | 10c6f1fe4f530af5c2032ebfce19c4fe29d39642 (patch) | |
tree | 846d6cb7874bdd40ad74888cacda1be714125398 /platform/ios/src/MGLMapView.mm | |
parent | c4fc89977bcba83ed5de87dcc8de1a68e8a31541 (diff) | |
download | qtlocation-mapboxgl-10c6f1fe4f530af5c2032ebfce19c4fe29d39642.tar.gz |
[ios] Match gesture recognizer with map view user interaction state
Diffstat (limited to 'platform/ios/src/MGLMapView.mm')
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 51 |
1 files changed, 40 insertions, 11 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 212f8934e4..fe3f12b152 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -240,6 +240,8 @@ public: @property (nonatomic) UIActionSheet *attributionSheet; @property (nonatomic, readwrite) MGLStyle *style; @property (nonatomic) UITapGestureRecognizer *singleTapGestureRecognizer; +@property (nonatomic) UITapGestureRecognizer *doubleTap; +@property (nonatomic) UITapGestureRecognizer *twoFingerTap; @property (nonatomic) UIPanGestureRecognizer *pan; @property (nonatomic) UIPinchGestureRecognizer *pinch; @property (nonatomic) UIRotationGestureRecognizer *rotate; @@ -515,26 +517,26 @@ public: [self addGestureRecognizer:_rotate]; _rotateEnabled = YES; - UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTapGesture:)]; - doubleTap.numberOfTapsRequired = 2; - [self addGestureRecognizer:doubleTap]; + _doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTapGesture:)]; + _doubleTap.numberOfTapsRequired = 2; + [self addGestureRecognizer:_doubleTap]; _singleTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTapGesture:)]; - [_singleTapGestureRecognizer requireGestureRecognizerToFail:doubleTap]; + [_singleTapGestureRecognizer requireGestureRecognizerToFail:_doubleTap]; _singleTapGestureRecognizer.delegate = self; [self addGestureRecognizer:_singleTapGestureRecognizer]; - UITapGestureRecognizer *twoFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTwoFingerTapGesture:)]; - twoFingerTap.numberOfTouchesRequired = 2; - [twoFingerTap requireGestureRecognizerToFail:_pinch]; - [twoFingerTap requireGestureRecognizerToFail:_rotate]; - [self addGestureRecognizer:twoFingerTap]; + _twoFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTwoFingerTapGesture:)]; + _twoFingerTap.numberOfTouchesRequired = 2; + [_twoFingerTap requireGestureRecognizerToFail:_pinch]; + [_twoFingerTap requireGestureRecognizerToFail:_rotate]; + [self addGestureRecognizer:_twoFingerTap]; _twoFingerDrag = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handleTwoFingerDragGesture:)]; _twoFingerDrag.minimumNumberOfTouches = 2; _twoFingerDrag.maximumNumberOfTouches = 2; _twoFingerDrag.delegate = self; - [_twoFingerDrag requireGestureRecognizerToFail:twoFingerTap]; + [_twoFingerDrag requireGestureRecognizerToFail:_twoFingerTap]; [_twoFingerDrag requireGestureRecognizerToFail:_pan]; [self addGestureRecognizer:_twoFingerDrag]; _pitchEnabled = YES; @@ -544,7 +546,7 @@ public: _quickZoom = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleQuickZoomGesture:)]; _quickZoom.numberOfTapsRequired = 1; _quickZoom.minimumPressDuration = 0; - [_quickZoom requireGestureRecognizerToFail:doubleTap]; + [_quickZoom requireGestureRecognizerToFail:_doubleTap]; [self addGestureRecognizer:_quickZoom]; // observe app activity @@ -2128,6 +2130,33 @@ public: _mbglMap->onLowMemory(); } +- (void)setZoomEnabled:(BOOL)zoomEnabled +{ + _zoomEnabled = zoomEnabled; + self.pinch.enabled = zoomEnabled; + self.doubleTap.enabled = zoomEnabled; + self.quickZoom.enabled = zoomEnabled; + self.twoFingerTap.enabled = zoomEnabled; +} + +- (void)setScrollEnabled:(BOOL)scrollEnabled +{ + _scrollEnabled = scrollEnabled; + self.pan.enabled = scrollEnabled; +} + +- (void)setRotateEnabled:(BOOL)rotateEnabled +{ + _rotateEnabled = rotateEnabled; + self.rotate.enabled = rotateEnabled; +} + +- (void)setPitchEnabled:(BOOL)pitchEnabled +{ + _pitchEnabled = pitchEnabled; + self.twoFingerDrag.enabled = pitchEnabled; +} + #pragma mark - Accessibility - - (NSString *)accessibilityValue |