-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Support function objects in Leaflet options. #1943
Comments
I'm not sure if I completely follow, could you maybe give a short code snippet as an example? Is this about allowing any Folium Update: is this maybe what you mean? #1856 |
It's something different from #1856. To a certain extent it is about allowing any Folium class' As an example: if one looks at the I would like the user to be able to create a E.g.
|
My plan of approach would be Step 1 Step 2 |
I think this can be closed with release 0.19.0 |
Is your feature request related to a problem? Please describe.
This is not so much a problem as rather a cleanup. All leaflet objects can be configured using an
options
dictionary. Many of these objects allow javascript functions insideoptions
. So far in Folium, these javascript functions were typically implemented in the folium templates and could not be supplied by users. (With a few exceptions).Describe the solution you'd like
We can use
JsCode
to allow users to create javascript functions as part of the configuration. SeveralLayer
s could benefit from this addition. For instance: folium.GeoJson could be extended with methods foron_each_feature
andpoint_to_layer
. By adding javascript method handlers, we increase the flexibility of the user. It would allow the user more interactivity. E.g. showing something else in a popup than just the properties of a geojson layer, or adding new shapes.Describe alternatives you've considered
The main alternative is that we do nothing. This has the advantage of keeping Folium simple. However, the extra power and flexibility outweigh the additional complexity. (At least in my view). It would probably be best to document these as advanced features.
Additional context
I noted that in several locations, the folium objects generate their own implementations of javascript options. E.g. folium.GeoJson generates an
on_each_feature
object if a popup or tooltip is configured. We would need to decide how to handle this. The easiest solution would be to disallow certain combinations. Staying with the GeoJson example, if you passon_each_feature
you cannot also pass apopup
ortooltip
argument.Implementation
folium is maintained by volunteers. Can you help make a PR if we want to implement this feature?
The text was updated successfully, but these errors were encountered: