Skip to content

Polyline highlight color #1763

Closed
Closed

Description

@fm-sys

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.

Activity

  1. added
    enhancement
    on May 22, 2023
  2. Conengmo commented on May 22, 2023

    @Conengmo
    Member

    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: https://nbviewer.org/github/python-visualization/folium/blob/main/examples/Highlight_Function.ipynb

  3. fm-sys commented on May 22, 2023

    @fm-sys
    Author

    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 👍

  4. IndigoWizard commented on Aug 12, 2023

    @IndigoWizard

    @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:

    Folium draw and highlight polylines with distinct colours from unique GeoJSON

    Results - before hover Results - on hover/highlight
       
  5. fm-sys commented on Aug 13, 2023

    @fm-sys
    Author

    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.

  6. Conengmo commented on Aug 15, 2023

    @Conengmo
    Member

    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.

  7. fm-sys commented on Jul 11, 2026

    @fm-sys
    Author

    Let's close here. See #1866 (comment) for explanation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions