Skip to main content

Function: GeoVisLayerControl()

GeoVisLayerControl(__namedParameters?): Element | null

Defined in: ui/GeoVisLayerControl.tsx:159

Floating panel of layer-visibility toggles, driven entirely by spec.control and auto-mounted by <GeoVisProvider> — consumers never place it manually.

It renders a collapsed trigger button anchored to a map corner; expanding it (on hover or click, per control.trigger) reveals one button per control.items entry. Clicking an item flips the visibility of its referenced layers via dispatch({ type: 'toggle-layer' }).

Each item has three visual states: active (its layers are shown), inactive (its layers are hidden), and disabled (none of its layers exist in the current spec — the button is greyed and non-interactive). The on/off choice is remembered by item.id and re-applied whenever the spec changes, so hiding a layer persists across spec rebuilds (e.g. map-mode switches) as long as the control remains present.

With control.maxVisibleItems set and more items than that, the panel shows the items that are on, then the first of the rest, plus a "Ver mais" card; clicking it swaps in a larger panel with every item — sectioned by each item's category — which stays open until closed (its close button, Escape, a click outside, or the trigger) — even for the 'hover' trigger. The strip's order is read when the panel opens and held while it is open.

With control.maxActiveItems set, switching an item on past the limit switches off the one on longest.

An entry with items is a category (LayerControlGroup): its card shows how many of its items are on, and clicking it opens a panel of those items — held open the same way, with a back button to the view it was opened from. A control without categories is exactly a flat list of toggles.

Renders null when spec.control is absent.

Parameters​

ParameterTypeDescription
__namedParameters{ expanded?: boolean; onExpandedChange?: (expanded) => void; trailing?: ReactNode; }-
__namedParameters.expanded?booleanWhether the panel is open. Omit to let the control own that state — the default. Pass it (with onExpandedChange) to coordinate the panel with a sibling overlay: below the compact breakpoint <GeoVisProvider> does exactly that, so opening the legend closes this panel and vice versa, since both claim the space above the trigger row.
__namedParameters.onExpandedChange?(expanded) => voidCalled with the requested open state. Required for expanded to take effect.
__namedParameters.trailing?ReactNodeExtra control rendered beside the trigger, inside the same anchored row. Used below the compact breakpoint to sit the legend button next to this one; the two then share a single corner anchor instead of each computing its own offset and colliding when this control's panel opens sideways.

Returns​

Element | null