I have a bunch of polygons which are stored in a database. I would like to add them to the map in such a way that they can be edited using the leaflet-draw toolbar. Although, now the polygons get added to the map, I am unable edit them.
I think this is because they are not added to the layerGroup()
to which newly drawn shapes are added.
Please help.
You have to add your polygons to the featureGroup
drawnItems
! Let's say,is your database array with polygons. First create a feature group with your drawn items:
and add it to the map:
Then you simply need to iterate over your polygons in your database and add them to the drawenItems
FeatureGroup
:Now the layers are added to the map and editable.
Here goes an EXAMPLE: