Leaflet / Leaflet.Editable

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

Grid Snap Editing #190

Open nathron opened 5 years ago

nathron commented 5 years ago

I need to edit polygon vertices snapping to a grid (integer coordinates). I tried using leaflet.snap, but that will snap to the lines and not the intersections, so I captured editable:vertex:dragend and adjusted vertex position. I don't get how it is possible to move the corresponding polygon vertex under the handle

map.on('editable:vertex:dragend', function (e) { var lat = (Math.round(e.vertex.latlng.lat)); var lng = (Math.round(e.vertex.latlng.lng)); var newLatLng = new L.LatLng(lat, lng); e.vertex.setLatLng(newLatLng); }