1717from branca .utilities import (_locations_tolist , _parse_size , image_to_url , iter_points , none_max , none_min ) # noqa
1818
1919from folium .map import FeatureGroup , Icon , Layer , Marker , Popup
20- from folium .utilities import _parse_path , _validate_coordinates , _validate_location
20+ from folium .utilities import _parse_path , _parse_wms , _validate_coordinates , _validate_location
2121
2222from jinja2 import Template
2323
@@ -34,11 +34,11 @@ class WmsTileLayer(Layer):
3434 The url of the WMS server.
3535 name : string, default None
3636 The name of the Layer, as it will appear in LayerControls
37- layers : str, default None
37+ layers : str, default ''
3838 The names of the layers to be displayed.
39- styles : str, default None
39+ styles : str, default ''
4040 Comma-separated list of WMS styles.
41- fmt : str, default None
41+ fmt : str, default 'image/jpeg'
4242 The format of the service output.
4343 Ex: 'image/png'
4444 transparent: bool, default True
@@ -61,34 +61,20 @@ class WmsTileLayer(Layer):
6161 http://leafletjs.com/reference.html#tilelayer-wms
6262
6363 """
64- def __init__ (self , url , name = None , layers = None , styles = None , fmt = None ,
65- transparent = True , version = '1.1.1' , attr = None , overlay = True ,
66- control = True , ** kwargs ):
64+ def __init__ (self , url , name = None , attr = '' , overlay = True , control = True , ** kwargs ):
6765 super (WmsTileLayer , self ).__init__ (overlay = overlay , control = control , name = name ) # noqa
6866 self .url = url
69- self .attribution = attr if attr is not None else ''
7067 # Options.
71- self .layers = layers if layers else ''
72- self .styles = styles if styles else ''
73- self .fmt = fmt if fmt else 'image/jpeg'
74- self .transparent = transparent
75- self .version = version
76- self .kwargs = kwargs
68+ options = _parse_wms (** kwargs )
69+ options .update ({'attribution' : attr })
70+
71+ self .options = json .dumps (options , sort_keys = True , indent = 2 )
72+
7773 self ._template = Template (u"""
7874 {% macro script(this, kwargs) %}
7975 var {{this.get_name()}} = L.tileLayer.wms(
8076 '{{ this.url }}',
81- {
82- {% for key, value in this.kwargs.items() %}
83- {{key}}: '{{ value }}',
84- {% endfor %}
85- layers: '{{ this.layers }}',
86- styles: '{{ this.styles }}',
87- format: '{{ this.fmt }}',
88- transparent: {{ this.transparent.__str__().lower() }},
89- version: '{{ this.version }}',
90- {% if this.attribution %} attribution: '{{this.attribution}}'{% endif %}
91- }
77+ {{ this.options }}
9278 ).addTo({{this._parent.get_name()}});
9379
9480 {% endmacro %}
@@ -825,10 +811,10 @@ class Circle(Marker):
825811 See http://leafletjs.com/reference-1.2.0.html#path for more otions.
826812
827813 """
828- def __init__ (self , location , radius = 10 , popup = None , ** kw ):
814+ def __init__ (self , location , radius = 10 , popup = None , ** kwargs ):
829815 super (Circle , self ).__init__ (_validate_location (location ), popup = popup )
830816 self ._name = 'circle'
831- options = _parse_path (** kw )
817+ options = _parse_path (** kwargs )
832818
833819 options .update ({'radius' : radius })
834820 self .options = json .dumps (options , sort_keys = True , indent = 2 )
0 commit comments