Skip to content

Allow non-standard params on WmsTileLayer #420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions folium/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class WmsTileLayer(Layer):
"""
def __init__(self, url, name=None, layers=None, styles=None, format=None,
transparent=True, version='1.1.1', attr=None, overlay=True,
control=True):
control=True, **kwargs):
super(WmsTileLayer, self).__init__(overlay=overlay, control=control, name=name) # noqa
self.url = url
self.attribution = attr if attr is not None else ''
Expand All @@ -63,6 +63,9 @@ def __init__(self, url, name=None, layers=None, styles=None, format=None,
self.format = format if format else 'image/jpeg'
self.transparent = transparent
self.version = version
self.extra_params = []
for name, value in kwargs.items():
self.extra_params.append((name, value))
# FIXME: Should be map CRS!
# self.crs = crs if crs else 'null
self._template = Template(u"""
Expand All @@ -74,8 +77,9 @@ def __init__(self, url, name=None, layers=None, styles=None, format=None,
styles: '{{ this.styles }}',
format: '{{ this.format }}',
transparent: {{ this.transparent.__str__().lower() }},
version: '{{ this.version }}',
{% if this.attribution %} attribution: '{{this.attribution}}'{% endif %}
version: '{{ this.version }}'
{% if this.attribution %}, attribution: '{{this.attribution}}'{% endif %}
{% for param in this.extra_params %}, {{param.0}}: '{{param.1}}'{% endfor %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bielfrontera thanks for the PR!

I wonder if you should be explicit here about the extra parameter instead of looping over the kwargs. What do you think @BibMartin?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the extra parameters are those included in ncWMS.

But at SOCIB we have extended that library with parameters as markerscale and markerspacing.

Copy link
Member

@ocefpaf ocefpaf Apr 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bielfrontera I am 👍 to all that. I am just concerned if we should be explicit here, by naming every option, instead of looping over the kwargs.

Copy link
Member

@ocefpaf ocefpaf Aug 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bielfrontera where do you stand on adding those parameters explicitly instead of looping over them? We also need to update the docs to describe them. At least the most important subset you expect to use frequently.

}
).addTo({{this._parent.get_name()}});

Expand Down
18 changes: 18 additions & 0 deletions tests/test_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,21 @@ def test_color_line():
opacity=1)
m.add_child(color_line)
m._repr_html_()


# WmsTileLayer. Non-standard params
def test_non_standard_params_wms_service():
m = Map([40, -100], zoom_start=4)
url = 'http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi'
w = features.WmsTileLayer(url,
name='test',
format='image/png',
layers='nexrad-n0r-900913',
attr=u"Weather data © 2012 IEM Nexrad",
colorscalerange='auto',
transparent=True)
w.add_to(m)
m._repr_html_()

bounds = m.get_bounds()
assert bounds == [[None, None], [None, None]], bounds