@un-fao/visualization@0.1.0-review.1
    Preparing search index...

    DataOverlay

    DataOverlay mounts deck.gl layers as a control inside a react-map-gl/maplibre map. MapLibre owns camera state and navigation input. The supported non-interleaved mode creates a separate Deck canvas and WebGL context and internally derives the view synchronized with the map.

    Choose DataViewport instead when no map owns your camera. Start here explains the choices; DataOverlay and DataOverlayProps provide the full API.

    Install the complete package peer set. Installed peers and imports used by this example are different things.

    DataOverlay must be rendered inside a MapLibre-backed Map. It returns no DOM content of its own; the overlay control manages its dedicated Deck canvas. Load MapLibre's stylesheet so its canvas and controls use the required layout.

    import {
    DataOverlay,
    type DataOverlayProps,
    } from '@un-fao/visualization';
    import 'maplibre-gl/dist/maplibre-gl.css';
    import { Map } from 'react-map-gl/maplibre';

    const overlayProps = {
    layers: [],
    useDevicePixels: true,
    } satisfies DataOverlayProps;

    export function MapVisualization() {
    return (
    <div style={{ height: 480, width: '100%' }}>
    <Map
    initialViewState={{ longitude: 0, latitude: 0, zoom: 2 }}
    mapStyle={{ version: 8, sources: {}, layers: [] }}
    >
    <DataOverlay {...overlayProps} />
    </Map>
    </div>
    );
    }
    Module Import Purpose Why or when
    @un-fao/visualization DataOverlay Runtime-required Mounts the package's public overlay inside the surrounding map.
    @un-fao/visualization DataOverlayProps Optional type-only Checks the overlay prop object without adding runtime JavaScript.
    maplibre-gl/dist/maplibre-gl.css side effect Runtime-required Loads MapLibre's layout rules for the rendered map and controls.
    react-map-gl/maplibre Map Runtime-required Provides the MapLibre map that owns this overlay's camera.

    The empty style and layers: [] show the wiring without fetching external data; they deliberately produce no basemap features or raster. Add a single-raster or collection layer to layers, and choose a map view covering it. If your host is @un-fao/map's MapViewport, nest DataOverlay inside it in the same way; install that separate package too.

    Prop Type Required? Default Ownership and effect
    layers LayersList Optional No package default Inherited from MapboxOverlay. Supplies the deck.gl layers rendered over the surrounding map.
    useDevicePixels number | boolean Optional No package default Inherited from MapboxOverlay. Controls the dedicated Deck canvas pixel ratio in the supported overlaid mode.
    onLoad () => void Optional No package default Inherited from MapboxOverlay. Runs when the internally managed Deck instance finishes initialization.
    onAfterRender (context: { device: Device; gl: WebGL2RenderingContext; }) => void Optional No package default Inherited from MapboxOverlay. Observes completed overlay render passes and must remain lightweight.

    All focused props are optional in the selected package declaration. “No package default” means DataOverlay does not substitute a value. Consult the exact MapboxOverlay API for upstream behavior and defaults.

    Consumers cannot supply interleaved, viewState, initialViewState, controller, parent, canvas, device, or views. MapLibre owns camera state and interaction. The overlay internally owns its separate Deck canvas and graphics context and derives the synchronized view. Only upstream interleaved mode shares MapLibre's context, and this package does not expose that mode.

    Later prop changes are forwarded to the mounted overlay. Removing or unmounting DataOverlay removes the control and releases its resources. Consumers remain responsible for accessible surrounding controls and non-canvas alternatives.

    If the overlay is blank, check the surrounding map context, dimensions, layer data and map bounds. Configure interaction and view state on the map, not the overlay. Overlay onLoad means its Deck instance initialized, not that all remote raster reads have completed.