MCPcopy Index your code
hub / github.com/python-visualization/folium / LayerControl

Class LayerControl

folium/map.py:189–283  ·  view source on GitHub ↗

Creates a LayerControl object to be added on a folium map. This object should be added to a Map object. Only Layer children of Map are included in the layer control. Note ---- The LayerControl should be added last to the map. Otherwise, the LayerControl and/or the cont

Source from the content-addressed store, hash-verified

187
188
189class LayerControl(MacroElement):
190 """
191 Creates a LayerControl object to be added on a folium map.
192
193 This object should be added to a Map object. Only Layer children
194 of Map are included in the layer control.
195
196 Note
197 ----
198 The LayerControl should be added last to the map.
199 Otherwise, the LayerControl and/or the controlled layers may not appear.
200
201 Parameters
202 ----------
203 position : str
204 The position of the control (one of the map corners), can be
205 'topleft', 'topright', 'bottomleft' or 'bottomright'
206 default: 'topright'
207 collapsed : bool, default True
208 If true the control will be collapsed into an icon and expanded on
209 mouse hover or touch.
210 autoZIndex : bool, default True
211 If true the control assigns zIndexes in increasing order to all of
212 its layers so that the order is preserved when switching them on/off.
213 draggable: bool, default False
214 By default the layer control has a fixed position. Set this argument
215 to True to allow dragging the control around.
216 **kwargs
217 Additional (possibly inherited) options. See
218 https://leafletjs.com/reference.html#control-layers
219
220 """
221
222 _template = Template(
223 """
224 {% macro script(this,kwargs) %}
225 var {{ this.get_name() }}_layers = {
226 base_layers : {
227 {%- for key, val in this.base_layers.items() %}
228 {{ key|tojson }} : {{val}},
229 {%- endfor %}
230 },
231 overlays : {
232 {%- for key, val in this.overlays.items() %}
233 {{ key|tojson }} : {{val}},
234 {%- endfor %}
235 },
236 };
237 let {{ this.get_name() }} = L.control.layers(
238 {{ this.get_name() }}_layers.base_layers,
239 {{ this.get_name() }}_layers.overlays,
240 {{ this.options|tojavascript }}
241 ).addTo({{this._parent.get_name()}});
242
243 {%- if this.draggable %}
244 new L.Draggable({{ this.get_name() }}.getContainer()).enable();
245 {%- endif %}
246

Calls 1

TemplateClass · 0.90

Tested by 4

test_layer_control_resetFunction · 0.72