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

highlight_color for vector classes #1866

Conversation

yschopfer19
Copy link

The implementation introduces the possibility to highlight polylines, polygons, rectangles, circles, and circle markers if a tooltip is shown.
Changes Made:

  • Users can now specify the "highlight_color" when creating a vector layer.
  • When a user hovers over the vector layer and a tooltip is displayed, the vector layer then sets its color to the highlight color.

Related Issue: #1763

Copy link
Member

@Conengmo Conengmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working in this @yschopfer19! I’m on mobile so I haven’t looked into this that detailed yet, but I wanted to share my first thought. Which is that I’d rather avoid adding the repeated code. Maybe you can think of a way to have that extra template code only in one place?

I do like the idea of having highlight functionality on vector classes, but if the code becomes much longer or more complex I’m not sure if it’s worth it.

I hope you’re not discouraged by this. And if you want I can help with this as well later.

thanks again for your effort!

hansthen added a commit to hansthen/folium that referenced this pull request Mar 14, 2024
In combination with JsCode this makes it easier for users to
add `on` method calls for event handling without extending
Folium itself.

The functionality was inspired by PR python-visualization#1866 by @yschopfer19.
The PR was not accepted yet, because of concerns with code
duplication. In the approach taken in the current PR, python-visualization#1866 would
not be necessary anymore, as the requested changes could be added
completely in client code space.
hansthen added a commit to hansthen/folium that referenced this pull request May 18, 2024
In combination with JsCode this makes it easier for users to
add `on` method calls for event handling without extending
Folium itself.

The functionality was inspired by PR python-visualization#1866 by @yschopfer19.
The PR was not accepted yet, because of concerns with code
duplication. In the approach taken in the current PR, python-visualization#1866 would
not be necessary anymore, as the requested changes could be added
completely in client code space.
Conengmo added a commit that referenced this pull request Jun 2, 2024
* Add EventHandler to layer object

In combination with JsCode this makes it easier for users to
add `on` method calls for event handling without extending
Folium itself.

The functionality was inspired by PR #1866 by @yschopfer19.
The PR was not accepted yet, because of concerns with code
duplication. In the approach taken in the current PR, #1866 would
not be necessary anymore, as the requested changes could be added
completely in client code space.

* Make realtime inherit from Layer

* Changes after review comments by conengmo

* Updates after review comments

* Add extra docstring line

* Add Evented class

In Leaflet Evented is the parent class of both `L.Map` and `L.Layer`.
It adds the `on` method which can be used to add event handlers
to a leaflet object.

* Update folium/map.py

Co-authored-by: Frank Anema <[email protected]>

* Update folium/map.py

Co-authored-by: Frank Anema <[email protected]>

* As requested in review comment

---------

Co-authored-by: Frank Anema <[email protected]>
@Conengmo
Copy link
Member

Since #1959 was merged maybe that can be used for this functionality.

@hansthen
Copy link
Collaborator

hansthen commented Jul 1, 2024

@yschopfer19 By now we implemented #1959, which allows users to add javascript event handlers. It allows users to do what you proposed in your PR.

If #1959 does not serve your need, please let us know.

@hansthen hansthen closed this Oct 5, 2024
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

Successfully merging this pull request may close these issues.

3 participants