gi-nx / updateLayerTreeVisibility
ts
function updateLayerTreeVisibility(layerTree: LayerTree): void;Apply the visibility, opacity and (for groups) enabled state of a layerTree to the map. Use this to write back a tree you have read from giraffeState.get('layerTree') and edited — for example after toggling a group's enabled flag or a layer's visible/opacity. Layer order and tree structure (adding/removing items) are not changed; only per-item state is applied.
Parameters
| Parameter | Type |
|---|---|
layerTree | LayerTree |
Returns
void
Example
ts
import { giraffeState } from '@gi-nx/iframe-sdk';
// Read the current layer tree (clone so we don't mutate live state).
const layerTree = structuredClone(giraffeState.get('layerTree'));
// Turn a group off, then write the edited tree back.
const group = layerTree.items['My Group'];
group.data = { ...group.data, enabled: false };
updateLayerTreeVisibility(layerTree);