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

FeatureGroups named using numeric string always placed first in LayerControl #2021

Open
JuliusGoelz opened this issue Oct 30, 2024 · 0 comments

Comments

@JuliusGoelz
Copy link

Describe the bug
Adding multiple FeatureGroups to a LayerControl where some are named using a numerical string causes those groups to always come first in the layer control on the map, even though feature groups named using alphanumeric strings are unsorted and sortLayers argument is set to False.

Screenshot:

grafik

I have not managed to find any documentation saying that this is intended behaviour.

To Reproduce

import folium

m = folium.Map(location=[0, 0], zoom_start=6)

fg1 = folium.FeatureGroup("z")
m.add_child(fg1)

fg2 = folium.FeatureGroup("a")
m.add_child(fg2)

fg3 = folium.FeatureGroup("2a")
m.add_child(fg3)

fg4 = folium.FeatureGroup("1")
m.add_child(fg4)

folium.Marker([-1, -1]).add_to(fg1)
folium.Marker([1, 1]).add_to(fg2)
folium.Marker([-1, 1]).add_to(fg3)
folium.Marker([1, -1]).add_to(fg4)

folium.LayerControl(collapsed=False, sortLayers=False).add_to(m)

m

Expected behavior
FeatureGroups appearing in the LayerControl in the order they were added to the map when sortLayers argument is set to False.

In the case of the example: z -> a -> 2a -> 1

Environment (please complete the following information):

  • Jupyter Notebook
  • Python version: 3.12.6
  • folium version 0.18.0

Additional context

--

Possible solutions

  • Inserting a space/any other symbol after the number makes it appear where I would expect it to
  • I tried supplying a js sortFunction to LayerControl as a string, but it resulted in the layer control not showing up. Is this not supposed to be used in Python?
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

1 participant