Skip to content

Commit 23c13bb

Browse files
Biel Fronterabielfrontera
Biel Frontera
authored andcommitted
Allow non-standard params on WmsTileLayer
1 parent f6c2d9f commit 23c13bb

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

folium/features.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class WmsTileLayer(Layer):
5353
"""
5454
def __init__(self, url, name=None, layers=None, styles=None, format=None,
5555
transparent=True, version='1.1.1', attr=None, overlay=True,
56-
control=True):
56+
control=True, **kwargs):
5757
super(WmsTileLayer, self).__init__(overlay=overlay, control=control, name=name) # noqa
5858
self.url = url
5959
self.attribution = attr if attr is not None else ''
@@ -63,6 +63,9 @@ def __init__(self, url, name=None, layers=None, styles=None, format=None,
6363
self.format = format if format else 'image/jpeg'
6464
self.transparent = transparent
6565
self.version = version
66+
self.extra_params = []
67+
for name, value in kwargs.items():
68+
self.extra_params.append((name, value))
6669
# FIXME: Should be map CRS!
6770
# self.crs = crs if crs else 'null
6871
self._template = Template(u"""
@@ -74,8 +77,9 @@ def __init__(self, url, name=None, layers=None, styles=None, format=None,
7477
styles: '{{ this.styles }}',
7578
format: '{{ this.format }}',
7679
transparent: {{ this.transparent.__str__().lower() }},
77-
version: '{{ this.version }}',
78-
{% if this.attribution %} attribution: '{{this.attribution}}'{% endif %}
80+
version: '{{ this.version }}'
81+
{% if this.attribution %}, attribution: '{{this.attribution}}'{% endif %}
82+
{% for param in this.extra_params %}, {{param.0}}: '{{param.1}}'{% endfor %}
7983
}
8084
).addTo({{this._parent.get_name()}});
8185

tests/test_features.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,21 @@ def test_color_line():
133133
opacity=1)
134134
m.add_child(color_line)
135135
m._repr_html_()
136+
137+
138+
# WmsTileLayer. Non-standard params
139+
def test_non_standard_params_wms_service():
140+
m = Map([40, -100], zoom_start=4)
141+
url = 'http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi'
142+
w = features.WmsTileLayer(url,
143+
name='test',
144+
format='image/png',
145+
layers='nexrad-n0r-900913',
146+
attr=u"Weather data © 2012 IEM Nexrad",
147+
colorscalerange='auto',
148+
transparent=True)
149+
w.add_to(m)
150+
m._repr_html_()
151+
152+
bounds = m.get_bounds()
153+
assert bounds == [[None, None], [None, None]], bounds

0 commit comments

Comments
 (0)