Skip to content

Commit c14cb8f

Browse files
committed
WIP basic version of timeline control
1 parent 0f4d57f commit c14cb8f

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

folium/plugins/timeline.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
from branca.element import MacroElement
2+
from jinja2 import Template
3+
4+
from folium.elements import JSCSSMixin
5+
from folium.utilities import parse_options
6+
7+
8+
class Timeline(JSCSSMixin, MacroElement):
9+
"""
10+
TODO
11+
"""
12+
13+
_template = Template(
14+
"""
15+
{% macro script(this, kwargs) %}
16+
var {{ this.get_name() }} = L.timeline(
17+
{{ this.data|tojson }},
18+
{{ this.options|tojson }}
19+
);
20+
{{ this._parent.get_name() }}.addControl({{ this.get_name() }});
21+
{{ this.get_name() }}.addTo({{ this._parent.get_name() }});
22+
{% endmacro %}
23+
"""
24+
)
25+
26+
default_js = [
27+
(
28+
"timeline",
29+
"https://skeate.dev/Leaflet.timeline/examples/leaflet.timeline.js",
30+
)
31+
]
32+
33+
def __init__(self, data, **kwargs):
34+
super().__init__()
35+
self._name = "Timeline"
36+
37+
self.data = data
38+
self.options = parse_options(**kwargs)
39+
40+
41+
class TimelineSliderControl(JSCSSMixin, MacroElement):
42+
"""
43+
TODO
44+
"""
45+
46+
_template = Template(
47+
"""
48+
{% macro script(this, kwargs) %}
49+
var {{ this.get_name() }} = L.timelineSliderControl(
50+
{{ this.options|tojson }}
51+
);
52+
{{ this.get_name() }}.addTimelines();
53+
{{ this.get_name() }}.addTo({{ this._parent.get_name() }});
54+
{% endmacro %}
55+
"""
56+
)
57+
58+
default_js = [
59+
(
60+
"timeline",
61+
"https://skeate.dev/Leaflet.timeline/examples/leaflet.timeline.js",
62+
)
63+
]
64+
65+
def __init__(self, data, **kwargs):
66+
super().__init__()
67+
self._name = "TimelineSliderControl"
68+
69+
self.options = parse_options(**kwargs)

0 commit comments

Comments
 (0)