admin管理员组文章数量:1418669
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)
本文标签: Adding Leaflet plugin leafleticonpulse to Folium pluginsStack Overflow
版权声明:本文标题:Adding Leaflet plugin leaflet-icon-pulse to Folium plugins - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745292844a2651900.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论