-
Notifications
You must be signed in to change notification settings - Fork 2.2k
User guide LayerControl
example (controlling TileLayer
) doesn't work
#2093
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
Comments
LayerControl
example doesn't workLayerControl
example (controlling TileLayer
) doesn't work
From experimentation (and reading the rest of the page...) the problem is that So the example: m = folium.Map(tiles=None)
folium.TileLayer("OpenStreetMap").add_to(m)
folium.TileLayer(show=False).add_to(m)
folium.LayerControl().add_to(m)
m Should be [corrected]: m = folium.Map(tiles=None)
folium.TileLayer("OpenStreetMap", overlay=True).add_to(m)
folium.LayerControl().add_to(m)
m So it does what it describes "add a control to the map to show or hide layers". I don't think the |
Raised PR #2105. |
You are right. The documentation about Layers is confusing. I also ran into this when I first started out with Folium. Let me have a look at your PR over the weekend. I have not have had time to take a detailed look at the other issues you created, but I will block some time this weekend. |
On looking at this specific issue again, what I've written above doesn't make logical sense - I think I may be getting inconsistent/unexpected/buggy behaviour in my environment. I will try to put a set of test cases together so it's clear to me how things actually behave, and will make the PR draft. [Edit: resolved, simple copy/paste error on my part] |
Describe the bug
At https://python-visualization.github.io/folium/latest/user_guide/ui_elements/layer_control.html, the text says 'add a control to the map to show or hide layers'. But the demo (or local HTML produced by equivalent code on my machine) seems to have incorrect code, which adds the control but has no effect on the
TileLayer
.To Reproduce / Expected behavior
Environment (please complete the following information):
sys.version_info(major=3, minor=12, micro=5, releaselevel='final', serial=0)
Additional context/Possible solutions
If I change this in my local env:
To:
This partially fixes the problem - the OpenStreet map tiles are not initially visible, and the 'openstreetmap' control can be selected to make them visible, however the control cannot be deselected and so the tiles cannot be hidden again.
[Edit: I have only encountered this with a
TileLayer
- no issues controlling aFeatureGroup
with aLayerControl
]folium is maintained by volunteers. Can you help making a fix for this issue?
Maybe, depending on complex the docs setup is; need to understand root issue first.
The text was updated successfully, but these errors were encountered: