-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP basic version of timeline control
- Loading branch information
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |