mapbox-gl-native icon indicating copy to clipboard operation
mapbox-gl-native copied to clipboard

Handle Gestures

Open crazyBoat opened this issue 11 years ago • 9 comments

Hello, how I can handle gestures from mapview?

crazyBoat avatar Jun 19 '15 08:06 crazyBoat

Which platform are you using the map view on?

1ec5 avatar Jun 19 '15 14:06 1ec5

iOS

crazyBoat avatar Jun 19 '15 19:06 crazyBoat

MGLMapView handles standard gestures (swipe to pan, pinch to zoom, rotate with two fingers, etc.) by default. If you need to handle additional gestures, UIKit provides a set of gesture recognizer classes like UILongPressGestureRecognizer that help you handle gestures with minimal extra code.

Does this answer your question?

1ec5 avatar Jun 19 '15 19:06 1ec5

what is the best way to avoid conflicts between mapbox gestures and my personal implementation with gesture recogniser?

crazyBoat avatar Jun 19 '15 19:06 crazyBoat

If you’re looking to replace one of the built-in gestures, you can disable that gesture by setting rotateEnabled, scrollEnabled, or zoomEnabled to false. Otherwise, what kind of conflict are you trying to work around?

1ec5 avatar Jun 19 '15 21:06 1ec5

@crazyBoat you can implement the gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: method in the UIGestureRecognizerDelegate protocol to allow your gesture recognizer to pass through to the MGLMapView ones without interfering.

tomtaylor avatar Jun 22 '15 20:06 tomtaylor

Even after implementing gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: set to true, the pan gesture is not passing through to the map view.

andrewcar avatar Aug 22 '16 12:08 andrewcar

The suggestion in https://github.com/mapbox/mapbox-gl-native/issues/1758#issuecomment-114250985 was to use this method to intercept the gestures you don't want MGLMapView handling. Unconditionally returning true will always allow both gesture recognizers to fire simultaneously, which is probably not your intent.

1ec5 avatar Aug 22 '16 15:08 1ec5

Related: #2278.

1ec5 avatar Aug 22 '16 21:08 1ec5