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); }
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); }