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

Add Evented base class #1959

Merged
merged 9 commits into from
Jun 2, 2024
Merged

Conversation

hansthen
Copy link
Collaborator

@hansthen hansthen commented Jun 1, 2024

In Leaflet Evented is the parent class of Layer and Map.

It adds the on method, which can be used to add event handlers for the two type of Leaflet objects. In Leaflet it also adds methods to fire events and turn off event handlers. I did not implement those as they would be less relevant within Folium.

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.
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.
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.

Looks good! Let's do this. I added two small comments, but should be good to afterwards. We'll look into adding more to the docs later.

folium/map.py Outdated Show resolved Hide resolved
folium/map.py Outdated Show resolved Hide resolved
hansthen and others added 2 commits June 2, 2024 19:36
Co-authored-by: Frank Anema <33519926+Conengmo@users.noreply.github.com>
Co-authored-by: Frank Anema <33519926+Conengmo@users.noreply.github.com>
@hansthen hansthen requested a review from Conengmo June 2, 2024 17:37
@Conengmo Conengmo changed the title Evented Add Evented base class Jun 2, 2024
@Conengmo Conengmo merged commit 9fb5f2a into python-visualization:main Jun 2, 2024
12 checks passed
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.

2 participants