26
26
from folium .utilities import none_min , none_max , iter_points
27
27
28
28
class TimestampedGeoJson (MacroElement ):
29
- def __init__ (self , data , transition_time = 200 , loop = True , auto_play = True ):
29
+ def __init__ (self , data , transition_time = 200 , loop = True , auto_play = True ,
30
+ period = "P1D" ):
30
31
"""Creates a TimestampedGeoJson plugin to append into a map with
31
32
Map.add_children.
32
33
@@ -80,7 +81,13 @@ def __init__(self, data, transition_time=200, loop=True, auto_play=True):
80
81
Whether the animation shall loop.
81
82
auto_play : bool, default True
82
83
Whether the animation shall start automatically at startup.
83
-
84
+ period : str, default "P1D"
85
+ Used to construct the array of available times starting
86
+ from the first available time. Format: ISO8601 Duration
87
+ ex: "P1M" -> 1/month
88
+ "P1D" -> 1/day
89
+ "PT1H" -> 1/hour
90
+ "PT1M" -> 1/minute
84
91
"""
85
92
super (TimestampedGeoJson , self ).__init__ ()
86
93
self ._name = 'TimestampedGeoJson'
@@ -98,10 +105,11 @@ def __init__(self, data, transition_time=200, loop=True, auto_play=True):
98
105
self .transition_time = int (transition_time )
99
106
self .loop = bool (loop )
100
107
self .auto_play = bool (auto_play )
108
+ self .period = period
101
109
102
110
self ._template = Template ("""
103
111
{% macro script(this, kwargs) %}
104
- {{this._parent.get_name()}}.timeDimension = L.timeDimension();
112
+ {{this._parent.get_name()}}.timeDimension = L.timeDimension({period:"{{this.period}}"} );
105
113
{{this._parent.get_name()}}.timeDimensionControl = L.control.timeDimension({
106
114
position: 'bottomleft',
107
115
autoPlay: {{'true' if this.auto_play else 'false'}},
0 commit comments