map
The high-level engines that wire a core!Scene, a backend, and d3-zoom together: geoMap (a project-once map engine over GeoJSON) and plot (a generic 2D engine driven by per-datum draw callbacks). createBackend selects the rendering backend by BackendType.
import { plot } from "@mapequation/d3gl/map";
plot(el, { width, height }).layer("links", data, { draw: (ctx, d) => { ctx.moveTo(d.x0, d.y0); ctx.lineTo(d.x1, d.y1); }, stroke: "#888",});Classes
Section titled “Classes”| Class | Description |
|---|---|
| GeoMap | - |
| HighlightBuilder | Builder handed to custom hover/highlight draw fns, scoped to ONE source drawable. Everything recorded lands in the overlay group (drawn on top, inheriting the source layer’s clipTo/sizeMode). World coordinates throughout. Geometry comes from the Scene’s already-projected subpaths/circles — no re-projection, no datum re-processing. |
| LayerHandle | A handle to one registered layer, returned by GeoMap.layer, Plot.layer, and Plot.points. Lets you stream more data into the layer via append without re-projecting or re-building the features already in it. |
| Plot | - |
| Tooltip | A single shared, absolutely-positioned, pointer-events-none tooltip div in the host. Created lazily on first show; default inline look unless a className is given (then styling is entirely the caller’s). Always carries d3gl-tooltip. |
Interfaces
Section titled “Interfaces”| Interface | Description |
|---|---|
| BackendHandle | - |
| BaseEngineOptions | Options every engine shares, owned and consumed once by the BaseEngine constructor. Each engine’s options type (e.g. GeoMapOptions, PlotOptions) extends this and adds only its own fields, so a base-level setting is declared in exactly one place and can’t drift or be silently dropped by an engine that forgot to wire it. |
| EngineSizing | How an engine is sized. Sizing is responsive by default — the engine observes its host and resizes in place (no teardown), preserving layers, view, and interaction state: |
| GeoMapOptions | Options every engine shares, owned and consumed once by the BaseEngine constructor. Each engine’s options type (e.g. GeoMapOptions, PlotOptions) extends this and adds only its own fields, so a base-level setting is declared in exactly one place and can’t drift or be silently dropped by an engine that forgot to wire it. |
| HighlightStyle | Style for highlight-overlay geometry. Unlike bulk StyleOverrides, lineWidth IS allowed: only one item is re-tessellated per hover change. |
| HoverHit | - |
| InteractiveLayerOptions | Declarative interaction options shared by every engine’s retained layers. The machinery (hover overlay, tooltip, selection styling, hit-testing) lives entirely in BaseEngine — these options are just the per-layer surface that both BaseEngine.select’s and the hover/tooltip dispatch read. Plot.layer()/Plot.points() and GeoMap.layer() forward them into the LayerSpec via BaseEngine.interactionFields, so the contract has one home. |
| LayerOptions | Declarative interaction options shared by every engine’s retained layers. The machinery (hover overlay, tooltip, selection styling, hit-testing) lives entirely in BaseEngine — these options are just the per-layer surface that both BaseEngine.select’s and the hover/tooltip dispatch read. Plot.layer()/Plot.points() and GeoMap.layer() forward them into the LayerSpec via BaseEngine.interactionFields, so the contract has one home. |
| PlotLayerOptions | Declarative interaction options shared by every engine’s retained layers. The machinery (hover overlay, tooltip, selection styling, hit-testing) lives entirely in BaseEngine — these options are just the per-layer surface that both BaseEngine.select’s and the hover/tooltip dispatch read. Plot.layer()/Plot.points() and GeoMap.layer() forward them into the LayerSpec via BaseEngine.interactionFields, so the contract has one home. |
| PlotOptions | Plot adds no engine-level options of its own — all of BaseEngineOptions (sizing, backend, tooltipClass) apply. |
| PlotPointOptions | Declarative interaction options shared by every engine’s retained layers. The machinery (hover overlay, tooltip, selection styling, hit-testing) lives entirely in BaseEngine — these options are just the per-layer surface that both BaseEngine.select’s and the hover/tooltip dispatch read. Plot.layer()/Plot.points() and GeoMap.layer() forward them into the LayerSpec via BaseEngine.interactionFields, so the contract has one home. |
| SelectionOptions | Styles for select(): the selected set and its complement. Defaults: selected keeps the base style (items stand out because the others dim); others is { opacity: 0.3 }. |
| StyleOverride | Bulk per-drawable style override, composed over the base colors the layer’s fill/stroke accessors produce. Colors only — stroke geometry has its width baked in at tessellation time, so a bulk width change would be O(n) re-tessellation (widths are available in the single-item highlight overlay instead). |
Type Aliases
Section titled “Type Aliases”| Type Alias | Description |
|---|---|
| BackendType | Which renderer an engine (GeoMap / Plot, or the React <GeoMap>) draws the core!Scene with. Geometry is projected & tessellated once (backend-independent); the backend only turns it into pixels (or SVG nodes). Defaults to "webgl". |
| HChild | A minimal hyperscript helper: build a detached DOM element tree declaratively, with no framework and no HTML-string parsing. It’s the un-sugared React.createElement model — handy for the rich content the engine tooltip option accepts ((d) => HTMLElement), or any HTML overlay. |
| HighlightDraw | - |
| HoverOption | The hover layer option: true = default style, a style = replay with it, a function = full custom draw of the hovered item. |
Functions
Section titled “Functions”| Function | Description |
|---|---|
| createBackend | - |
| createCanvasBackend | Synchronously create a Canvas backend + its |
| geoMap | - |
| h | - |
| plot | - |