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

className not propagated to leaflet path options on markers as otherwise indicated by folium docs #2024

Open
klausfrandsen opened this issue Nov 4, 2024 · 0 comments

Comments

@klausfrandsen
Copy link

For Markers, CircleMarkers, etc. if adding className as an extra kwarg, it is not propagated to the js-code initializing the leaflet map, even though the documentation somewhat suggests it:
**kwargs
Other valid (possibly inherited) options. See:
https://leafletjs.com/reference.html#circlemarker

Having the possibility to add class-strings to the generated map, greatly improves the usability of Folium (at least for me), as it allows the developer to add extra interactivity client-side in javascript via simple css selectors, e.g. hiding showing selected stuff on the map on js-events.

To Reproduce
Add className='my_class_str' to any Marker.
Inspect map in browser and e.g. search for my_class_str.
It does not show up.

Expected behavior
class = "my_class_str" added to html elements for Markers

Environment (please complete the following information):

  • chrome
  • html files
  • Python version: 3.9
  • folium version: 0.14.0
  • branca version: 0.6.0

Additional context
Seems like this might have been reported before:
#730
But if it was fixed or not seems unclear to me

Possible solutions
Seems like there is a VERY simple fix, by just adding "className": kwargs.pop("className", '') when initializing the default dict in path_options() in vector_layers.py
It works for me, but I do not know if there are use-cases I'm unaware of, or if it results in other unwanted side-effects.

Thanks for a great package!

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