-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Comments
I can at least confirm the behavior. However, I also cannot see anything wrong with the generated code on our side. We keep the order in which the items are added to the map. Perhaps it is an issue with the underlying Leaflet code. |
There is a comment similar to yours in this merge request Leaflet/Leaflet#4227, where they also note that numerical keys break the sort order. |
@JuliusGoelz This seems to be an issue with an upstream package. You might want to file your issue with the Leaflet project. However, since the issues is already known I would not hold your breath for them to fix it anytime to soon. |
@hansthen Thank you for looking into it! The issue can be closed as far as I'm concerned, I'm just not quite sure which of the two options to choose, though. |
@JuliusGoelz I think your first solution would be perfect as a workaround. Your second solution (providing a custom javascript sort function) should also work. However, you must make sure to wrap the javascript code in a JsCode object. There are some examples on how to do that here: https://python-visualization.github.io/folium/latest/user_guide/plugins/realtime.html. |
Describe the bug
Adding multiple
FeatureGroup
s to aLayerControl
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 andsortLayers
argument is set toFalse
.Screenshot (edited, original one accidentally showed the solution using the workaround described below):
I have not managed to find any documentation saying that this is intended behaviour.
To Reproduce
Expected behavior
FeatureGroup
s appearing in theLayerControl
in the order they were added to the map whensortLayers
argument is set toFalse
.In the case of the example: z -> a -> 2a -> 1
Environment (please complete the following information):
Additional context
--
Possible solutions
sortFunction
toLayerControl
as a string, but it resulted in the layer control not showing up. Is this not supposed to be used in Python?The text was updated successfully, but these errors were encountered: