Created
September 14, 2021 22:33
-
-
Save stefanocudini/1336853cd805bdd83132397be1795be5 to your computer and use it in GitHub Desktop.
leaflet draggable polygon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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