Leaflet.Editable icon indicating copy to clipboard operation
Leaflet.Editable copied to clipboard

Option to Prevent Polygon/Polyline Intersection?

Open jcarenza opened this issue 8 years ago • 2 comments

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!

jcarenza avatar Apr 07 '16 14:04 jcarenza

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

mikeatm avatar May 06 '16 11:05 mikeatm

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.

newmanw avatar Sep 25 '17 19:09 newmanw