leafletgeojsonleaflet-geoman

Dragging/moving multiple geojsons on leaflet-geoman


I'd like to move/drag geojson features on map so that the distance to each other stays the same.

Choose geojsons by clicking them and then dragging them together. How should I make this?

Thanks!

I read about syncLayersOnDrag but can not get it to work.


Solution

  • If you set syncLayersOnDrag after adding the layer, it works

    // data are coming from smaple-geojson.js
    const geoLayer = L.geoJSON([bicycleRental, campus]).addTo(map)
    map.fitBounds(geoLayer.getBounds())
    
    map.pm.setGlobalOptions({
        syncLayersOnDrag: true
    });
    

    https://jsfiddle.net/zba1ogjL/