Folium: Show/Hide Selected Overlays (was question re: the layer checkbox)

Created on 13 Mar 2017  路  6Comments  路  Source: python-visualization/folium

Good day! I was reading one of @ocefpaf 's post and stumbled upon this. https://ocefpaf.github.io/python4oceanographers/blog/2015/03/23/wms_layers/ . How can I make a layer group unchecked on load like the example given on the post? Thanks!

bug

Most helpful comment

Can we have this as a feature? Haha Add a parameter to a layer group that will determine if it is checked/unchecked on load? Like here, on the Programmatic Display section: https://rstudio.github.io/leaflet/showhide.html. I'll try to tinker around this. Thanks!

All 6 comments

That is a bug we introduced in the latest version that needs fixing. (PRs welcomed :wink:)

Can we have this as a feature? Haha Add a parameter to a layer group that will determine if it is checked/unchecked on load? Like here, on the Programmatic Display section: https://rstudio.github.io/leaflet/showhide.html. I'll try to tinker around this. Thanks!

I tried two different implementations for a default visibility setting for overlays:

  1. Add this functionality to class LayerControl by accepting a list with names of overlays to hide on load. This works fine, but you have to remember which layers you want to hide until adding layer control.

  2. Add a hide parameter to class Layer. Then each child class would also need to accept this extra parameter.

Both end up being used in the template in class LayerControl. I add a layer_object.remove(); line for each layer that should be hidden by default.

I'm new to this scene and didn't find any guidelines so please advice on how to proceed.

I am more inclined to solution number 2.

Allright, I'll make a WIP pull request later for you to see. I'll wait with adding this to all the classes until we're sure this is the way to go.

I was going through the issues and noticed this functionality is the same as asked for in #571.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

agravier picture agravier  路  26Comments

spanishinquistion picture spanishinquistion  路  16Comments

nathan3leaf picture nathan3leaf  路  32Comments

AntonioLopardo picture AntonioLopardo  路  15Comments

ispmarin picture ispmarin  路  17Comments