Skip to content

Commit 6f87a1d

Browse files
committed
support for multiple time enabled wms layers, to be passed as a list or other iterable
1 parent 174caec commit 6f87a1d

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

folium/plugins/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from .fullscreen import Fullscreen
1717
from .polyline_text_path import PolyLineTextPath
1818
from .float_image import FloatImage
19-
from .timestamped_wmstilelayer import TimestampedWmsTileLayer
19+
from .timestamped_wmstilelayer import TimestampedWmsTileLayers
2020

2121
__all__ = [
2222
'MarkerCluster',

folium/plugins/timestamped_wmstilelayer.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from ..map import Layer
2626

2727

28-
class TimestampedWmsTileLayer(Layer):
28+
class TimestampedWmsTileLayers(Layer):
2929
def __init__(self, data, transition_time=200, loop=False, auto_play=False,
3030
period="P1D"):
3131
"""Creates a TimestampedWmsTileLayer subclass of Layer that takes a
@@ -55,8 +55,8 @@ def __init__(self, data, transition_time=200, loop=False, auto_play=False,
5555
w.add_to(m)
5656
5757
# Add WmsTileLayer to time control
58-
time = plugins.TimestampedWmsTileLayer(w)
59-
time.add_to(m)
58+
time = plugins.TimestampedWmsTileLayers(w)
59+
time.add_to([m,])
6060
6161
transition_time : int, default 200.
6262
The duration in ms of a transition from between timestamps.
@@ -85,9 +85,8 @@ def __init__(self, data, transition_time=200, loop=False, auto_play=False,
8585
self.loop = bool(loop)
8686
self.auto_play = bool(auto_play)
8787
self.period = period
88-
self.layer = data
88+
self.layers = data
8989
self._template = Template("""
90-
print kwargs
9190
{% macro script(this, kwargs) %}
9291
{{this._parent.get_name()}}.timeDimension = L.timeDimension({period:"{{this.period}}"});
9392
{{this._parent.get_name()}}.timeDimensionControl = L.control.timeDimension({
@@ -99,12 +98,13 @@ def __init__(self, data, transition_time=200, loop=False, auto_play=False,
9998
});
10099
{{this._parent.get_name()}}.addControl({{this._parent.get_name()}}.timeDimensionControl);
101100
102-
103-
var {{this.get_name()}} = L.timeDimension.layer.wms({{ this.layer.get_name() }},
101+
{% for layer in this.layers %}
102+
var {{this.get_name()}} = L.timeDimension.layer.wms({{ layer.get_name() }},
104103
{updateTimeDimension: true,
105-
wmsVersion: '{{ this.layer.version }}',
104+
wmsVersion: '{{ layer.version }}',
106105
}
107106
).addTo({{this._parent.get_name()}});
107+
{% endfor %}
108108
{% endmacro %}
109109
""")
110110

0 commit comments

Comments
 (0)