Is it possible to make a layer consisting of several objects draggable in leaflet?

Viewed 471

I would like to make a group of objects simultaneously draggable, so that they can only be dragged together. That means: if I move one object, the other objects in the layer will be moved to. In particular I have a geojson file with a featureCollection consisting of several objects and I want them to be draggable but behave as a single marker on the map.

So far I have:

var mymap = L.map('mapid').setView...
...

var drag = L.geoJson(null,{
    draggable: true,
});

omnivore.geojson('data.geojson', null, drag).addTo(mymap)

I have included Leaflet.Path.Drag to make the geojson objects draggable.

In the result every feature in the geojson feature collection is draggable independently. How can I couple them?

1 Answers
Related