bluehalo / ngx-leaflet-draw

MIT License
88 stars 29 forks source link

push drawn Layers into leafletLayers #55

Closed Zahma closed 5 years ago

Zahma commented 6 years ago

its logic that the drawn layers should be appended to leafletlayers, so what I did basically is the following:

this.map.on(L.Draw.Event.CREATED, (e) => {
            let layer: any = e.layer;
            this.layers.push(layer);  
 });

the problem is that the push is not instantly reflected into the map. A click event should be performed before saying the layer on the map. why is that happening ?!

reblace commented 6 years ago

Check this out, it describes how change detection works when you're making changes inside of Leaflet events:

https://github.com/Asymmetrik/ngx-leaflet#a-note-about-change-detection

Basically, you just need to trigger change detection when you make changes inside of event handlers that are outside of Angular's zone.

reblace commented 5 years ago

Closing this as answered.