createOverlay.system#getLayer¶
Summary¶
createOverlay.system#getLayer looks up a registered overlay layer by id. Use it to call a layer-specific setter when the caller only has its registration id.
Syntax¶
OverlaySystem.getLayer<T extends OverlayLayer = OverlayLayer>(id: string): T | null
const legend = overlays.getLayer<LegendLayer>("legend");
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
id |
string |
Yes | Exact registration id. |
Returns¶
T | null - The registered layer, including a disabled layer, or null for an unknown id. This is the original object. The optional type argument is a TypeScript assertion about the expected layer type.
Example¶
import { LegendLayer } from "@zushah/wasmgpu";
const overlays = wgpu.createOverlay.system();
overlays.addLayer(wgpu.createOverlay.legend({
id: "legend",
source: { scaleTransform: { domainMin: 0, domainMax: 100 }, colormap: "viridis" }
}));
const legend = overlays.getLayer("legend");
if (legend instanceof LegendLayer) legend.setSubtitle("Temperature");
overlays.destroy();