17
17
from branca .utilities import (_locations_tolist , _parse_size , image_to_url , iter_points , none_max , none_min ) # noqa
18
18
19
19
from 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
21
21
22
22
from jinja2 import Template
23
23
@@ -34,11 +34,11 @@ class WmsTileLayer(Layer):
34
34
The url of the WMS server.
35
35
name : string, default None
36
36
The name of the Layer, as it will appear in LayerControls
37
- layers : str, default None
37
+ layers : str, default ''
38
38
The names of the layers to be displayed.
39
- styles : str, default None
39
+ styles : str, default ''
40
40
Comma-separated list of WMS styles.
41
- fmt : str, default None
41
+ fmt : str, default 'image/jpeg'
42
42
The format of the service output.
43
43
Ex: 'image/png'
44
44
transparent: bool, default True
@@ -61,34 +61,20 @@ class WmsTileLayer(Layer):
61
61
http://leafletjs.com/reference.html#tilelayer-wms
62
62
63
63
"""
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 ):
67
65
super (WmsTileLayer , self ).__init__ (overlay = overlay , control = control , name = name ) # noqa
68
66
self .url = url
69
- self .attribution = attr if attr is not None else ''
70
67
# 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
+
77
73
self ._template = Template (u"""
78
74
{% macro script(this, kwargs) %}
79
75
var {{this.get_name()}} = L.tileLayer.wms(
80
76
'{{ 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 }}
92
78
).addTo({{this._parent.get_name()}});
93
79
94
80
{% endmacro %}
@@ -825,10 +811,10 @@ class Circle(Marker):
825
811
See http://leafletjs.com/reference-1.2.0.html#path for more otions.
826
812
827
813
"""
828
- def __init__ (self , location , radius = 10 , popup = None , ** kw ):
814
+ def __init__ (self , location , radius = 10 , popup = None , ** kwargs ):
829
815
super (Circle , self ).__init__ (_validate_location (location ), popup = popup )
830
816
self ._name = 'circle'
831
- options = _parse_path (** kw )
817
+ options = _parse_path (** kwargs )
832
818
833
819
options .update ({'radius' : radius })
834
820
self .options = json .dumps (options , sort_keys = True , indent = 2 )
0 commit comments