You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Like MKAnnotationView in MapKit, MGLAnnotationView should have a draggable property that, when set to YES, allows the user the relocate the annotation by long-pressing on it and dragging it. During the dragging gesture, the map remains still. (MKPinAnnotationView additionally levitates slightly above the map while being dragged and animates the beginning and end of the gesture.)
The Android SDK equivalent of this feature is being tracked in #2450.
Until this feature is implemented, the workaround is to keep track of the annotation yourself; when the user long-presses at a given location, check if the gesture took place at the annotation’s coordinates. If it did, set the map view’s scrollEnabled to NO and install your own pan gesture recognizer that changes the annotation’s coordinates.
Just pushed a branch that seems to be working well. It's still WiP as I'm not aware of all the implications.
I'm hesitating about if the view should handle updating the position or if that should be delegated back to the implementer through MGLMapViewDelegate or MGLAnnotationViewDelegate (annotationViewWasDraggedToLocation:) but that would prevent an otherwise very simple implementation of draggable views by just changing one property.
I do get the concerns about using two gesture recognizers per view but I don't see any performance decrease comparing 1000 draggable vs 1000 non-draggable annotation views.
Not a fan of updating the mapView property on the annotationView in MGLMapView -updateAnnotationViews so let me know if you have any good ideas how to get around that.
Activity
1ec5 commentedon May 14, 2016
Until this feature is implemented, the workaround is to keep track of the annotation yourself; when the user long-presses at a given location, check if the gesture took place at the annotation’s coordinates. If it did, set the map view’s
scrollEnabledtoNOand install your own pan gesture recognizer that changes the annotation’s coordinates.[ios] WiP #5036 draggable annotation views
frederoni commentedon Jun 7, 2016
Just pushed a branch that seems to be working well. It's still WiP as I'm not aware of all the implications.
I'm hesitating about if the view should handle updating the position or if that should be delegated back to the implementer through
MGLMapViewDelegateorMGLAnnotationViewDelegate(annotationViewWasDraggedToLocation:) but that would prevent an otherwise very simple implementation of draggable views by just changing one property.I do get the concerns about using two gesture recognizers per view but I don't see any performance decrease comparing 1000 draggable vs 1000 non-draggable annotation views.
Not a fan of updating the
mapViewproperty on the annotationView inMGLMapView -updateAnnotationViewsso let me know if you have any good ideas how to get around that.[ios] fixes #5036 draggable annotation views
[ios] fixes #5036 draggable annotation views
[ios] fixes #5036 draggable annotation views
[ios] fixes #5036 draggable annotation views (#5373)