Skip to content

Commit

Permalink
WIP basic version of timeline control
Browse files Browse the repository at this point in the history
  • Loading branch information
hansthen committed Jan 17, 2024
1 parent 0f4d57f commit c14cb8f
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions folium/plugins/timeline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from branca.element import MacroElement
from jinja2 import Template

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


class Timeline(JSCSSMixin, MacroElement):
"""
TODO
"""

_template = Template(
"""
{% macro script(this, kwargs) %}
var {{ this.get_name() }} = L.timeline(
{{ this.data|tojson }},
{{ this.options|tojson }}
);
{{ this._parent.get_name() }}.addControl({{ this.get_name() }});
{{ this.get_name() }}.addTo({{ this._parent.get_name() }});
{% endmacro %}
"""
)

default_js = [
(
"timeline",
"https://skeate.dev/Leaflet.timeline/examples/leaflet.timeline.js",
)
]

def __init__(self, data, **kwargs):
super().__init__()
self._name = "Timeline"

self.data = data
self.options = parse_options(**kwargs)


class TimelineSliderControl(JSCSSMixin, MacroElement):
"""
TODO
"""

_template = Template(
"""
{% macro script(this, kwargs) %}
var {{ this.get_name() }} = L.timelineSliderControl(
{{ this.options|tojson }}
);
{{ this.get_name() }}.addTimelines();
{{ this.get_name() }}.addTo({{ this._parent.get_name() }});
{% endmacro %}
"""
)

default_js = [
(
"timeline",
"https://skeate.dev/Leaflet.timeline/examples/leaflet.timeline.js",
)
]

def __init__(self, data, **kwargs):
super().__init__()
self._name = "TimelineSliderControl"

self.options = parse_options(**kwargs)

0 comments on commit c14cb8f

Please sign in to comment.