foliplus.LayerControl#

class foliplus.LayerControl(*, position: Literal['topleft', 'topright', 'bottomleft', 'bottomright'] = 'topleft', locale: str | LocaleConfig | None = None)[source]#

Bases: BaseControl

Drag-and-drop layer ordering with geometry icons, color picker, and panes.

  • 📐 Geometry-type icons for quick layer identification.

  • 🔀 Drag-and-drop reordering, synced to Leaflet render order.

  • ✅ Multi-select checkboxes with z-index stacking.

  • 🎨 Color picker to replace base maps with a solid background color.

  • 📂 Collapsible panel consistent with other foliplus controls.

Parameters#

positionstr, default “topleft”

One of "topleft", "topright", "bottomleft", "bottomright".

localestr or LocaleConfig, optional

Language code ("en", "zh") or a LocaleConfig instance. Defaults to auto-detection, falling back to English.

Notes#

Layer identification relies on map._layers and the window global variable at runtime. The initial layer list is collected during rendering by traversing the parent map’s children.

Examples#

>>> import folium
>>> from foliplus import LayerControl
>>> m = folium.Map()
>>> LayerControl().add_to(m)
__init__(*, position: Literal['topleft', 'topright', 'bottomleft', 'bottomright'] = 'topleft', locale: str | LocaleConfig | None = None)[source]#

Methods

__init__(*[, position, locale])

add_child(child[, name, index])

Add a child.

add_children(child[, name, index])

Add a child.

add_css_link(name, url)

Add or update css resource link.

add_js_link(name, url)

Add or update JS resource link.

add_to(parent[, name, index])

Add element to a parent.

get_bounds()

Computes the bounds of the object and all it's children in the form [[lat_min, lon_min], [lat_max, lon_max]].

get_name()

Returns a string representation of the object.

get_root()

Returns the root of the elements tree.

render(**kwargs)

Collect layers from the parent map before rendering.

save(outfile[, close_file])

Saves an Element into a file.

to_dict([depth, ordered])

Returns a dict representation of the object.

to_json([depth])

Returns a JSON representation of the object.

Attributes

default_css

default_js

render(**kwargs)[source]#

Collect layers from the parent map before rendering.

Traverses the parent map’s _children to find Layer instances, then populates self.base_layers and self.overlays according to each layer’s overlay flag.