Function: GeoVisLayerControl()
GeoVisLayerControl(
__namedParameters?):Element|null
Defined in: ui/GeoVisLayerControl.tsx:142
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
only the first ones plus a "Ver mais" card; clicking it swaps in a larger
panel with every item, which stays open until closed (its close button,
Escape, a click outside, or the trigger) — even for the 'hover' trigger.
Renders null when spec.control is absent.
Parameters
| Parameter | Type | Description |
|---|---|---|
__namedParameters | { expanded?: boolean; onExpandedChange?: (expanded) => void; trailing?: ReactNode; } | - |
__namedParameters.expanded? | boolean | Whether 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) => void | Called with the requested open state. Required for expanded to take effect. |
__namedParameters.trailing? | ReactNode | Extra 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