Closed incanus closed 10 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.
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:]
.
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.
Assigned to Tender discussion #1697.
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
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?
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
.
Assigned to MapBox iOS SDK #683. As reported in Tender:
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.