You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Polylines currently support showing a tooltip when clicking on them. Maybe it would be worth to add a highlight-color property, so the line can optionally be colored in a different style while the tooltip is shown.
Alternatively users need to add some custom JS code which might get ugly.
That's a nice suggestion. If somebody is willing to pick this up, that's welcome. I'm thinking it could be an argument for all vector classes, either implemented as a kwarg or as a separate class.
Alternatively, you could convert your data to geojson format and use the highlight_function argument of the GeoJson class. We have an example of that here
Thanks for letting me know about the workaround, exactly what I need 👍
@fm-sys As @Conengmo said, you can do it through the highlight_function of folium.features.GeoJson when using a GeoJSON for your polyline. I encountered the issue before and solved it through this, take a look at the solution I posted a while back:
I have successfully used the GeoJson workaround meanwhile... From my side this issue can be closed, but as I far as I understood @Conengmo we might want to track this idea for normal poly lines as well.
Thanks for your input both. Indeed let's keep this issue open, I like the idea of having this on vector classes as well, as long as it can be done in a simple way.
Activity
Conengmo commentedon May 22, 2023
That's a nice suggestion. If somebody is willing to pick this up, that's welcome. I'm thinking it could be an argument for all vector classes, either implemented as a kwarg or as a separate class.
Alternatively, you could convert your data to geojson format and use the
highlight_functionargument of theGeoJsonclass. We have an example of that here: https://nbviewer.org/github/python-visualization/folium/blob/main/examples/Highlight_Function.ipynbfm-sys commentedon May 22, 2023
Thanks for letting me know about the workaround, exactly what I need 👍
IndigoWizard commentedon Aug 12, 2023
@fm-sys As @Conengmo said, you can do it through the
highlight_functionoffolium.features.GeoJsonwhen using a GeoJSON for your polyline. I encountered the issue before and solved it through this, take a look at the solution I posted a while back:Folium draw and highlight polylines with distinct colours from unique GeoJSON
fm-sys commentedon Aug 13, 2023
I have successfully used the
GeoJsonworkaround meanwhile... From my side this issue can be closed, but as I far as I understood @Conengmo we might want to track this idea for normal poly lines as well.Conengmo commentedon Aug 15, 2023
Thanks for your input both. Indeed let's keep this issue open, I like the idea of having this on vector classes as well, as long as it can be done in a simple way.
fm-sys commentedon Jul 11, 2026
Let's close here. See #1866 (comment) for explanation