I am looking for a Leaflet pluging for move (drag and drop), rotate or change a polygon or polyline feature. Also I´d like to capture the feature vertex coordinates once it has been moved to the new position. Otherwise is it posible to do that using perhaps OpenLayers o TurfJS? Which is the most appropiated way to do that, including saving modified feature into the backend?
2 Answers
A quick search found this answer, so your question is possibly a duplicate question:
Using Leaflet.Path.Transform to rotate polygons in Mapbox
which leads to this leaflet plugin:
Leaflet.Path.Transform which has this beautiful demo page.
That looks like the answer to your question, minus the getting the feature coordinates, which might be solved by exploring the answers to this question: Coordinates of Leaflet.Draw rectangle
As for saving to the back-end, I would search something like 'leaflet draw save to [backend]'
-
1I have been exploring some plugins but not the mentioned. I will check that– kamomeApr 3, 2018 at 1:37
-
-
Maybe more of a long comment.. but:
The Leaflet.draw plugin covers most of the client-side functionality you're after - allowing users to draw/drag/edit etc.
But not rotate, which has been on an open request since 2013.
As noted by @Barrat you can use Leaflet.Path.Transform for rotation, however this won't play too nicely with Leaflet.draw (specifically, in terms of UX - they both provide their own interaction handlers which may conflict).
I've just started a plugin (Leaflet.draw.rotate) to merge the functionality of these two together, however it does not yet support rotating polygons/polylines (it is on the roadmap though).