Reputation: 626
I'm trying to load geojson from a database and edit particular shapes.
In my app I need to attach an ID to the drawn object so when I'm saving it I know which record to overwrite.
I've tried using leaflet.draw and leaflet.editable, and using the leaflet id of the object that is created. This id seems to be different between placing the polygon, and getting it from the editTools or features.
It must be a common requirement, but I can't find the code anywhere
Upvotes: 0
Views: 1278
Reputation: 166
You can use L.stamp(layer)
to get the internal id (or create it) of a layer - Stamp Util. It returns layer._leaflet_id
but since using private members is not recommended, stamp
is the straight API approach.
You can later retrieve the layer from a layerGroup with the getLayer method.
Upvotes: 1