bluehalo / ngx-leaflet-draw

MIT License
88 stars 29 forks source link

Edit manually added layers #82

Closed errolcruz18 closed 4 years ago

errolcruz18 commented 4 years ago

How can I edit layers added programmatically? When doing the below, the edit icon in the drawing control is saying no layer to edit.

For example I added a layer like this: const p = L.polygon([ [25.204382008439115, 55.25947952322895], [25.19708183190524, 55.25741958605069], [25.19670904490536, 55.26617431693013], [25.202611367966746, 55.264732361101785] ]) .bindPopup("

You are here

") .addTo(map);

or by this: ts file layers = [ L.polygon([ [25.204382008439115, 55.25947952322895], [25.19708183190524, 55.25741958605069], [25.19670904490536, 55.26617431693013], [25.202611367966746, 55.264732361101785] ]).bindPopup("

You are here

") ];

html file [leafletLayers]="layers"

Best,

reblace commented 4 years ago

See the README for details. To make layers editable, you have to add them to the featureGroup that was passed into the drawOptions object.