Git Product home page Git Product logo

Comments (3)

Conengmo avatar Conengmo commented on June 18, 2024

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.

hansthen avatar hansthen commented on June 18, 2024

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.

hansthen avatar hansthen commented on June 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.