Skip to content

Instantly share code, notes, and snippets.

@stefanocudini
Created September 14, 2021 22:33
Show Gist options
  • Save stefanocudini/1336853cd805bdd83132397be1795be5 to your computer and use it in GitHub Desktop.
Save stefanocudini/1336853cd805bdd83132397be1795be5 to your computer and use it in GitHub Desktop.
leaflet draggable polygon
//require https://github.com/w8r/Leaflet.Path.Drag
var imagePoly = [
imageBounds.getNorthEast(),
imageBounds.getNorthWest(),
imageBounds.getSouthWest(),
imageBounds.getSouthEast()
];
var poly = new L.Polygon([imagePoly], {
//draggable:true,
opacity: 1,
weight:5,
fillOpacity: 0
}).addTo(map);
poly.on('drag dragend', function (e) {
const bb = poly.getBounds()
imgs[0].setBounds(bb);
console.log(
bb.getNorthEast(),
bb.getSouthWest()
)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment