Skip to content

Commit

Permalink
WIP First version that sort of works
Browse files Browse the repository at this point in the history
  • Loading branch information
hansthen committed Jan 18, 2024
1 parent c14cb8f commit e930d85
Showing 1 changed file with 27 additions and 32 deletions.
59 changes: 27 additions & 32 deletions folium/plugins/timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,39 @@ class Timeline(JSCSSMixin, MacroElement):

_template = Template(
"""
{% macro header(this,kwargs) %}
<style>
.leaflet-bottom.leaflet-left {
width: 100%;
}
.leaflet-control-container .leaflet-timeline-controls {
box-sizing: border-box;
width: 100%;
margin: 0;
margin-bottom: 15px;
}
</style>
{% endmacro %}
{% 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)
var control = L.timelineSliderControl({
formatOutput: function (date) {
return new Date(date).toLocaleDateString();
},
enableKeyboardControls: true,
});
control.addTo({{ this._parent.get_name() }});
{{ this._parent.get_name() }}.addControl(control);
{{ this.get_name() }}.addTo({{ this._parent.get_name() }});
class TimelineSliderControl(JSCSSMixin, MacroElement):
"""
TODO
"""
control.addTimelines({{ this.get_name() }});
_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 %}
"""
)
Expand All @@ -64,6 +58,7 @@ class TimelineSliderControl(JSCSSMixin, MacroElement):

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

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

0 comments on commit e930d85

Please sign in to comment.