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)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745292844a4620964.html
评论列表(0条)