Leaflet / Leaflet.Editable

Make geometries editable in Leaflet.
http://leaflet.github.io/Leaflet.Editable/doc/api.html
559 stars 197 forks source link

Cancelable drag #155

Open newmanw opened 6 years ago

newmanw commented 6 years ago

Would be helpful to be able to cancel a drag event and snap the vertex back to its location before the drag started.

leandro commented 5 years ago

Yeah. I'm struggling on doing the same thing. I'm saving the lat/lng data on 'editable:vertex:mousedown' (because this event precedes both 'editable:vertex:dragstart' and 'editable:vertex:deleted', which is what I need). And then if a condition of mine is satisfied on 'editable:vertex:dragend' or 'editable:vertex:deleted', I push back a new vertex (into the polygon) in case of deletion through event.layer.editor.push(latlng) or through event.vertext.setLatLng(latlng) in case of dragend.

The thing is that I'm facing issues about the middle markers, editLayer and such. They are not updating properly. Not sure what is the recommended way doing such things. The approach used in one the repos' example (http://leaflet.github.io/Leaflet.Editable/example/undo-redo.html) doesn't work quite well for me, given the _drawingEditor it uses in the code doesn't exist in my case (editing an existing polygon that was turned into edit mode).

fofi commented 3 years ago

+, this would be great, Did someone found a workaround?