Pavan
Pavan

Reputation: 345

How to allow feature/polygon to be edited with Leaflet.draw?

i have a simple .json file and i draw it to map using leaflet, now it should be editable using leaflet.draw toolbar,and when ever we edit (marker,polygon..) its json file should be update. I don't have clue to implement it.

Upvotes: 0

Views: 1321

Answers (1)

Julien V
Julien V

Reputation: 895

Leaflet.Draw puts its editable layers in a featureGroup. When you defined L.Draw options, you may have written something like that :

edit: {
    featureGroup: editableLayers,
    remove: false
}

Every layer drawn by hand is added to editableLayers feature group. If you add each layers created by your json import in the feature group. They will be editable when you press the "edit" button. Abstract example :

var jsonlayer = new L.geoJson(jsoncontent, {
    onEachFeature: function(feature, layer){
        editableLayers.addLayer(layer);
    }
});

Upvotes: 1

Related Questions