1+ from typing import Optional , Union
2+
13from jinja2 import Template
24
35from folium .elements import JSCSSMixin
@@ -10,19 +12,26 @@ class VectorGridProtobuf(JSCSSMixin, Layer):
1012
1113 Parameters
1214 ----------
13- url: url to tile provider
15+ url: str
16+ url to tile provider
1417 e.g. https://free-{s}.tilehosting.com/data/v3/{z}/{x}/{y}.pbf?token={token}
15- layer_name: string, default "VectorGridLayer"
16- name of the layer
17- options: dict or str, VectorGrid.protobuf options
18-
19- For convenience you can pass VectorGrid.protobuf options as python dictionary or string.
18+ name: str, optional
19+ Name of the layer that will be displayed in LayerControl
20+ options: dict or str, optional
21+ VectorGrid.protobuf options, which you can pass as python dictionary or string.
2022 Strings allow plain JavaScript to be passed, therefore allow for conditional styling (see examples).
2123
2224 Additionally the url might contain any string literals like {token}, or {key}
2325 that can be passed as attribute to the options dict and will be substituted.
2426
2527 Every layer inside the tile layer has to be styled separately.
28+ overlay : bool, default True
29+ Whether your layer will be an overlay (ticked with a check box in
30+ LayerControls) or a base layer (ticked with a radio button).
31+ control: bool, default True
32+ Whether the layer will be included in LayerControls.
33+ show: bool, default True
34+ Whether the layer will be shown on opening.
2635
2736 Examples
2837 --------
@@ -100,12 +109,10 @@ class VectorGridProtobuf(JSCSSMixin, Layer):
100109 {% macro script(this, kwargs) -%}
101110 var {{ this.get_name() }} = L.vectorGrid.protobuf(
102111 '{{ this.url }}',
103- {% if this.options is defined %}
104- {{ this.options if this.options is string else this.options|tojson }})
105- .addTo({{ this._parent.get_name() }});
106- {% else %}
107- {{ this.options }});
108- {% endif %}
112+ {%- if this.options is defined %}
113+ {{ this.options if this.options is string else this.options|tojson }}
114+ {%- endif %}
115+ );
109116 {%- endmacro %}
110117 """
111118 )
@@ -117,13 +124,17 @@ class VectorGridProtobuf(JSCSSMixin, Layer):
117124 )
118125 ]
119126
120- def __init__ (self , url , layer_name , options = None ):
121- self .layer_name = layer_name if layer_name else "VectorGridProtobufLayer"
122-
123- super ().__init__ (name = self .layer_name )
124-
125- self .url = url
127+ def __init__ (
128+ self ,
129+ url : str ,
130+ name : Optional [str ] = None ,
131+ options : Union [str , dict , None ] = None ,
132+ overlay : bool = True ,
133+ control : bool = True ,
134+ show : bool = True ,
135+ ):
136+ super ().__init__ (name = name , overlay = overlay , control = control , show = show )
126137 self ._name = "VectorGridProtobuf"
127-
138+ self . url = url
128139 if options is not None :
129140 self .options = options
0 commit comments