Skip to content

worldwind-ui API / react-worldwind / useLayer

Function: useLayer() ​

useLayer<L>(create, deps, options?): L | null

Defined in: react/src/hooks.ts:167

Creates a WorldWind layer with create (synchronously or from a promise), adds it to the globe, and removes it on unmount or whenever deps change. The LayerOptions are reactive. *

Type Parameters ​

L ​

L extends WWLayer

Parameters ​

create ​

(globe) => L | Promise<L>

deps ​

DependencyList

options? ​

UseLayerOptions = {}

Returns ​

L | null

Example ​

tsx
const layer = useLayer((globe) => new globe.worldWind.TectonicPlatesLayer(), [], { opacity: 0.6 });

MIT licensed. Not affiliated with NASA; WorldWind is NASA's open-source virtual globe.