Leaflet.Editable
Leaflet.Editable copied to clipboard
Option to Prevent Polygon/Polyline Intersection?
Are there any existing options or functions to prevent intersections in polygons/polylines? I know that Leaflet-Draw has this option.
If this option doesn't currently exist, maybe a similar implementation would be feasible? Would someone be able to point me in the right direction of how to best approach this issue? I'll create a pull request if successful.
Thanks!
What you need is probably the convex hull algorith, already present in d3.js, here is a demo http://bl.ocks.org/mbostock/4341699 EDIT: probably not convex hull, check out this function in another leaflet plugin, follow it up, you should be able to get what you need: https://github.com/Leaflet/Leaflet.draw/blob/leaflet-master/dist/leaflet.draw-src.js#L1733
This would be helpful. I am currently using turfjs to check for intersection.
If you didn't want to add this check it would be helpful to send a 'cancelable' event from dragend such that a user can call e.cancel() to reset the vertex marker to its original position before the drag.