2626from folium .utilities import none_min , none_max , iter_points
2727
2828class 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" ):
3031 """Creates a TimestampedGeoJson plugin to append into a map with
3132 Map.add_children.
3233
@@ -80,7 +81,13 @@ def __init__(self, data, transition_time=200, loop=True, auto_play=True):
8081 Whether the animation shall loop.
8182 auto_play : bool, default True
8283 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
8491 """
8592 super (TimestampedGeoJson , self ).__init__ ()
8693 self ._name = 'TimestampedGeoJson'
@@ -98,10 +105,11 @@ def __init__(self, data, transition_time=200, loop=True, auto_play=True):
98105 self .transition_time = int (transition_time )
99106 self .loop = bool (loop )
100107 self .auto_play = bool (auto_play )
108+ self .period = period
101109
102110 self ._template = Template ("""
103111 {% macro script(this, kwargs) %}
104- {{this._parent.get_name()}}.timeDimension = L.timeDimension();
112+ {{this._parent.get_name()}}.timeDimension = L.timeDimension({period:"{{this.period}}"} );
105113 {{this._parent.get_name()}}.timeDimensionControl = L.control.timeDimension({
106114 position: 'bottomleft',
107115 autoPlay: {{'true' if this.auto_play else 'false'}},
0 commit comments