I am wondering if it's possible to use Leaflet.FreeDraw with leaflet.path.drag to be able to drag the polygon created by FreeDraw plugin.
I tried to enable dragging plugin like this, but it doesn't work.
const map = new L.Map(document.querySelector('section.map'), { doubleClickZoom: false }).setView(LAT_LNG, 14);
L.tileLayer(TILE_URL).addTo(map);
const freeDraw = new FreeDraw({ mode: FreeDraw.ALL });
map.addLayer(freeDraw);
freeDraw.dragging.enable();
You could extract the bounds from the
FreeDraw
by listening to themarkers
event to create a polygon or other map object using leaflet enabled withdragging
. See working example below.You should consider whether you would like to disable the
FreeDraw after this
, using the optionleaveModeAfterCreate:true
as the user may get additional polygons when draggingNB. Also see working example on js-fiddle here https://jsfiddle.net/ytevLbgs/