Skip to content

react

React bindings. The D3GL component mounts a canvas, builds it from initial groups + a core!ViewTransform, renders, and hands back the headless MapController; GeoMap wraps the project-once map engine.

import { D3GL } from "@mapequation/d3gl/react";
<D3GL width={width} height={height} groups={groups} onReady={(c) => controllerRef.current = c} />
ClassDescription
MapControllerHeadless owner of the GPU map: a luma device, one GroupRenderer per named group, and an offscreen framebuffer used for pick / PNG / pixel readback.
InterfaceDescription
D3GLGroup-
D3GLProps-
GeoMapProps-
LayerPropsProps for a Layer child of Plot: the imperative engine.layer(name, data, opts) arguments expressed declaratively.
MapControllerOptions-
PlotProps-
PointsPropsProps for a Points child of Plot: the imperative engine.points(name, data, opts) arguments expressed declaratively.
FunctionDescription
D3GLA canvas-backed GPU map. The effect creates a MapController, applies the initial groups + transform, renders, and reports the controller via onReady. Group and transform prop changes are pushed to the controller without rebuild (recolor = texture write, pan/zoom = uniform). Recreated only when size changes.
GeoMap-
LayerDeclarative layer marker. Renders nothing; Plot reads its props and calls engine.layer(name, data, …). Sibling order = paint order.
PlotThe declarative non-geo plotting component. It wraps the imperative plot engine: an effect keyed on [width, height] creates the engine ONCE, reads its <Layer> / <Points> children and applies them as engine.layer / engine.points calls (sibling order = paint order), optionally enables zoom, renders, and calls onReady(engine). A [backend] effect calls engine.setBackend() (preserving the current zoom/pan and layers — no recreate). A children-change effect re-applies the layers/points to the live engine so content updates keep the current view.
PointsDeclarative point-set marker. Renders nothing; Plot reads its props and calls engine.points(name, data, …). Sibling order = paint order.