Skip to content

Commit 6fceaa0

Browse files
author
Biel Frontera
committed
Allow non-standard params on WmsTileLayer
1 parent eb51514 commit 6fceaa0

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
@@ -52,7 +52,7 @@ class WmsTileLayer(Layer):
5252
"""
5353
def __init__(self, url, name=None, layers=None, styles=None, format=None,
5454
transparent=True, version='1.1.1', attr=None, overlay=True,
55-
control=True):
55+
control=True, **kwargs):
5656
super(WmsTileLayer, self).__init__(overlay=overlay, control=control, name=name) # noqa
5757
self.url = url
5858
self.attribution = attr if attr is not None else ''
@@ -62,6 +62,9 @@ def __init__(self, url, name=None, layers=None, styles=None, format=None,
6262
self.format = format if format else 'image/jpeg'
6363
self.transparent = transparent
6464
self.version = version
65+
self.extra_params = []
66+
for name, value in kwargs.items():
67+
self.extra_params.append((name, value))
6568
# FIXME: Should be map CRS!
6669
# self.crs = crs if crs else 'null
6770
self._template = Template(u"""
@@ -73,8 +76,9 @@ def __init__(self, url, name=None, layers=None, styles=None, format=None,
7376
styles: '{{ this.styles }}',
7477
format: '{{ this.format }}',
7578
transparent: {{ this.transparent.__str__().lower() }},
76-
version: '{{ this.version }}',
77-
{% if this.attribution %} attribution: '{{this.attribution}}'{% endif %}
79+
version: '{{ this.version }}'
80+
{% if this.attribution %}, attribution: '{{this.attribution}}'{% endif %}
81+
{% for param in this.extra_params %}, {{param.0}}: '{{param.1}}'{% endfor %}
7882
}
7983
).addTo({{this._parent.get_name()}});
8084

tests/test_features.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,21 @@ def test_wms_service():
119119

120120
bounds = m.get_bounds()
121121
assert bounds == [[None, None], [None, None]], bounds
122+
123+
124+
# WmsTileLayer. Non-standard params
125+
def test_non_standard_params_wms_service():
126+
m = Map([40, -100], zoom_start=4)
127+
url = 'http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi'
128+
w = features.WmsTileLayer(url,
129+
name='test',
130+
format='image/png',
131+
layers='nexrad-n0r-900913',
132+
attr=u"Weather data © 2012 IEM Nexrad",
133+
colorscalerange='auto',
134+
transparent=True)
135+
w.add_to(m)
136+
m._repr_html_()
137+
138+
bounds = m.get_bounds()
139+
assert bounds == [[None, None], [None, None]], bounds

0 commit comments

Comments
 (0)