Build the control. Nothing is rendered or attached until MapLibre calls LayerSettingsWidget.onAdd.
Widget configuration; see LayerSettingsWidgetOptions.
Collapse the panel to the ⚙ button, or expand it again.
MapLibre IControl hook: the default corner when added without an explicit position.
The MapLibre ControlPosition 'top-right'.
MapLibre IControl hook: build the DOM, inject the (ref-counted) stylesheet, run the first
probe pass and start the re-probe poll. Called by map.addControl(...).
The map this control is being added to.
The control's root HTMLElement; also the element layersettingschange fires on.
MapLibre IControl hook: run every section's teardown, stop the poll, drop the map listener,
remove the root and release this instance's stylesheet reference.
Point the panel at a layer: tear down the current sections, re-probe, and expand.
The layer to open. null clears the panel. A layer not passed in the options
is adopted (and added to the header picker).
Re-run every unbuilt section's probe, then every built section's refresh callbacks. Called on
the poll and on the map's idle; call it directly when you know data has landed and want to
set pollMs: 0.
Collapse to the ⚙ button (true) or expand (false).
An embeddable, framework-agnostic MapLibre layer settings panel (a
maplibregl.IControl).One widget, many layer types. It does not know what class it was handed: each section probes the layer for the CAPABILITY it drives (
typeof layer.setColorMode === 'function') and for the DATA that makes the control meaningful (getClassifications().length,hasEdges(),sublayerStates().length), and renders only what genuinely exists. A knob the layer does not have is not drawn; a knob that exists but cannot act yet is drawn inert with the reason in its tooltip. Nothing is invented.Because every data probe is false at mount — a layer has no classes, no attribute fields and no sublayer tree until it streams — the widget re-probes on a poll (default 500 ms) and on the map's
idle, inserting late sections at their registry position. A section is never removed once built, so a class list that shrinks as tiles evict does not make the panel flicker.On each change it dispatches a DOM
CustomEvent('layersettingschange', { detail: LayerSettingChange, bubbles: true })on its root, so any framework can bind without coupling to this class.Example
Example
See
LayerSettingsWidgetOptions for the configuration fields.