Comments (3)
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 options
to have JsCode
values? I would like that, but not sure how (without touching every template).
Update: is this maybe what you mean? #1856
from folium.
It's something different from #1856. To a certain extent it is about allowing any Folium class' options
have JsCode
arguments. And you are right, it would involve touching a lot of templates, but the work can be subdivided into smaller steps.
As an example: if one looks at the L.GeoJson
documentation, the user can provide functions for pointToLayer
and onEachFeature
. This is currently not possible in Folium.
I would like the user to be able to create a folium.GeoJson
object with point_to_layer
and on_each_feature
function objects.
E.g.
geojson = GeoJson(
point_to_layer = JsCode("""
function(feature, latlng) {
if(feature.properties.type === "X")
return new CircleMarker(latlng, {radius: 10});
else
return new Circle(latlng, {radius: feature.properties.radius));
}
""")
)
from folium.
My plan of approach would be
Step 1
Go through all Folium children of branca.Element
and make sure that when the class accepts a **kwargs
argument that is passed to the Leaflet class, it will check if any of the arguments is a JsCode
object and convert it accordingly. Some Folium classes generate their own version of these javascript function objects. Like GeoJson. In that case ensure that the one from **kwargs
cannot blindly override the one generated in the Folium template.
Step 2
Go through all of the Folium children of branca.Element
that have a corresponding Leaflet class. If the Leaflet class documents function objects, add these as explicit arguments to the Folium class __init__
method and document them.
from folium.
Related Issues (20)
- backslashes in popup break page. HOT 9
- Folium loads two versions of bootstrap HOT 1
- Realtime plugin: load local GeoJson file HOT 8
- Add ability to add a dynamic text/title per frame when using TimestampedGeoJson HOT 2
- Possibility to show all points from geojson file with the realtime plugin. HOT 2
- Folium maps not displayed with Safari in Iphones HOT 1
- GeoJson style is not being applied correctly HOT 2
- Keep original size of image in CustomIcon
- NumPy 2.0 support HOT 4
- AttributeError: module 'folium' has no attribute 'plugins' HOT 1
- Marker with same ID results into broken html HOT 1
- Make Folium follow the Leaflet class hierarchy more closely HOT 4
- Add example pattern for pulling JsCode snippets from external javascript files HOT 9
- HTML does not work when run on mobile. HOT 2
- Blue Lines when using TimestampedGeoJson in Folium HOT 2
- Docs not quite representative of the real "latest" version? HOT 10
- No popup when clicking on specific icons (BeautifyIcon plugin) HOT 4
- Geocoder plugin not working in Google Chrome HOT 2
- Making a tooltip stay when clicked on a marker/shape HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from folium.