mapbox / mapbox-plugins-android

Mapbox Android Plugins are a collection of libraries that extend our other SDKs, helping you design powerful mapping features while the plugins handle most of the heavy lifting.
https://www.mapbox.com/android-docs/plugins/overview/
BSD 2-Clause "Simplified" License
241 stars 119 forks source link

Prevent annotation changes from invalidating unrelated drag actions #1159

Open TroyStopera opened 3 years ago

TroyStopera commented 3 years ago

Relates to, but does not resolve, #1029

Motivation for change

I have a use case where markers on the map are 'linked' together via lines. As the user drags a marker, it is necessary that the line is programmatically updated as well. Due to the current logic which ensures data integrity, updates to the associated lines invalidate/stop the drag action.

This simple change adds a new method to the DraggableAnnotationController which allows the AnnotationManager to notify the controller of more fine-grain changes to the map source. If the change wasn't to the dragged annotation, the drag will continue.

Future work

As stated above, this does not solve 1029, which asks that changes to certain attributes of a dragged annotation don't stop the drag action. For example, a circle should be able to change size while being dragged, as this does not logically interfere with the annotation moving.

Although not included in this PR, a solution to that could be to add a field/method to the Annotation class which computes a 'drag integrity hash' which hashes all fields that must remain static during a drag. When a drag starts, the DraggableAnnotationManager can take note of this hash. When notified of an update, the controller can check the current integrity hash of the annotation, and if it doesn't match the original stop the drag.

If that solution is agreeable, I can update this PR to include that.

troy-skydio commented 3 years ago

@LukasPaczos Note sure what I need to do to get eyes on this. I'd really like to get this working in master, so that I can update to the latest versions released by Mapbox.

LukasPaczos commented 3 years ago

Tagging @mapbox/maps-android here.

tobrun commented 3 years ago

CI needs to be restored for this repo before we will be able to merge