Open fiendish opened 6 years ago
I would like to give this a bump, currently it isn't possible to remove charts from the map without using hacks like the above. It would be nice if L.minichart would respect the removeLayer-function call as all other layers do.
Hi,
Sorry if my answer comes very late. Is this still a problem? With Leaflet 1.3.1, I can correctly add and remove "minichart" layers. The following code works for me:
mylayer = L.minichart([0, 0], {data: 1234, type:"pie", labels:"auto"}).addTo(map)
map.removeLayer(mylayer)
Are you using a different version of leaflet or doing something different?
Hi Francois, I can't really tell. I haven't done any web maps with Leaflet in the last months so I cannot give you more feedback on the matter. If I recall correctly, my problem with the map not removing the charts layer was related to minZoom and maxZoom restrictions on the chart layer. If I remember that right, the chart layer was not removed when the maxZoom restriction kicked in ...
The problem has actually been fixed in version 0.2.5 by @bthieurmel . Thank you for your feedbacks.
If you have a layer control, deactivating any charts layer never actually hides them like it should.
I had to add this to make it work (I have all my charts in an L.layerGroup):