mapbox / DEPRECATED-mapbox-ios-sdk

REPLACED – use https://www.mapbox.com/ios-sdk instead
https://github.com/mapbox/mapbox-gl-native
Other
323 stars 8 forks source link

use long press for annotations drags #181

Closed incanus closed 10 years ago

incanus commented 11 years ago

Assigned to MapBox iOS SDK #683. As reported in Tender:

Is there a way to implement touch and hold before dragging? Sometimes I want to move the map but I accidentally move the marker instead.

This should probably behave more like MapKit, where long presses on marker kick off a move routine, rather than a swift pan that happens to start on a moveable marker.

incanus commented 11 years ago

Let's leave this app-specific. An app could respond to a long-press via the delegate, set a property on the annotation, and return YES for the dragging delegate call, as well as taking care of up/move/down animations.

incanus commented 11 years ago

Reopening after some investigation into MapKit's behavior here. It's too difficult to transform the long press gesture into a drag while animating the annotation layer. We should follow the model laid out by -[MKAnnotation setDragState:animated:].

incanus commented 10 years ago

FWIW this isn't about transforming a long press gesture into a pan, but rather adjusting the long press's allowableMovement then listening to its UIGestureRecognizerStateChanged events.

incanus commented 10 years ago

Assigned to Tender discussion #1697.

incanus commented 10 years ago

Ok, this is all set and behaves much like MapKit now. Most of the feature notes are in https://github.com/mapbox/mapbox-ios-sdk/commit/1bab02e92cdf67c8e1cff45fc07bcc69d49c60e2

phazlett commented 10 years ago

It would be helpful if RMMapViewDelegate method didChangeDragState included the actual gesture recognizer state because gestures are continuous. For example, long-pressing and releasing on an annotation results in multiple invocations of didChangeDragState, one invocation for UIGestureRecognizerStateBegan and one invocation for UIGestureRecognizerStateEnded but the delegate currently has no way to know which state to respond to.

I've looked through the new dragging implementation and don't see how to determine a 'begin' state from an 'end' state. Is this possible?

incanus commented 10 years ago

I was trying to mirror Apple's API here. For beginning and ending, the delegate moves through a progression of RMMapLayerDragState. When it starts, the state becomes RMMapLayerDragStateStarting; you acknowledge and set this to RMMapLayerDragStateDragging when you're ready. When it ends, the state becomes RMMapLayerDragStateEnding; you acknowledge and set it to RMMapLayerDragStateNone. Both acknowledgements give you a chance to do begin/end animations or anything else. Granted, it's not in the delegate, but I would consider this specialized to the annotation and thus better handled in the annotation subclass.

As for something like distinguishing between starting and moving, I think the way to do this would be a combo of listening to the drag state change callback as well as KVO (or subclassing) to get at annotation.position.