Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Charts don't go away when overlay is deactivated in L.control.layers #6

Open
fiendish opened this issue Dec 29, 2017 · 4 comments
Open

Comments

@fiendish
Copy link

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):

function hide_charts(e) {
   e.layer.eachLayer(
      function(t) {
         if (t._chart) { t._chart.remove(); }
      }
   );
}
map.on('overlayremove', hide_charts)
 
@frankbroniewski
Copy link

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.

@FrancoisGuillem
Copy link
Contributor

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?

@frankbroniewski
Copy link

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 ...

@FrancoisGuillem
Copy link
Contributor

The problem has actually been fixed in version 0.2.5 by @bthieurmel . Thank you for your feedbacks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants