最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Adding Leaflet plugin leaflet-icon-pulse to Folium plugins - Stack Overflow

programmeradmin1浏览0评论

I'm trying to add a Leaflet plugin to Folium, leaflet-icon-pulse found here: . Using the Folium plugin template and following similar plugins like this one: .py

Does anyone have any experience with making these plugins that could point me in the right direction?

Thanks.

I have not yet been able to get it to work, here's what I've tried:

from branca.element import MacroElement
from jinja2 import Template

from folium.elements import JSCSSMixin
from folium.utilities import parse_options, remove_empty


class Pulse(JSCSSMixin, MacroElement):
    """
    Adds a pulsing icon to your map.

    See  for more information.
    """

    _template = Template(
        """
        {% macro script(this, kwargs) %}
            
            var {{this.get_name()}} = L.icon.pulse(
                {{this.options | tojson}}, {{this.options | tojson}}
            )
        
        
        {% endmacro %}
        """
    )  # noqa

    default_js = [
        (
            "Control.Pulse.js",
            ".Icon.Pulse.js?raw=true",
        )
    ]
    default_css = [
        (
            "Control.Pulse.css",
            ".Icon.Pulse.css?raw=true",
        )
    ]

    
    def __init__(
        self,
        
        **kwargs
    ):
        super().__init__()
        self._name = "Pulse"
        self.options = remove_empty(
            
            **kwargs
        )
        
        

And then called with:

marker = folium.Marker(
    location=[lon, lat],
   )


p = Pulse(
        
        color='red',
        iconSize=[20,20],
    
).add_to(marker)


marker.add_to(m)

发布评论

评论列表(0)

  1. 暂无评论