Skip to content

MapRenderer

Defined in: packages/core/src/renderer/map-renderer.ts:231

Main class for rendering maps from configuration

new MapRenderer(container, config, layers?, options?, sources?): MapRenderer

Defined in: packages/core/src/renderer/map-renderer.ts:294

ParameterTypeDefault value
containerstring | HTMLElementundefined
configobjectOutputTypeundefined
layers(objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<{ id: ZodString; layout: ZodOptional<ZodObject<{ }, "passthrough", ZodTypeAny, objectOutputType<{ }, ZodTypeAny, "passthrough">, objectInputType<{ }, ZodTypeAny, "passthrough">>>; metadata: ZodOptional<ZodRecord<ZodString, ZodAny>>; paint: ZodOptional<ZodObject<{ background-color: ZodOptional<ZodUnion<[ZodEffects<…, …, …>, ZodType<…, …, …>]>>; background-opacity: ZodOptional<ZodUnion<[ZodNumber, ZodType<…, …, …>]>>; background-pattern: ZodOptional<ZodUnion<[ZodString, ZodType<…, …, …>]>>; }, "passthrough", ZodTypeAny, objectOutputType<{ background-color: ZodOptional<ZodUnion<[…, …]>>; background-opacity: ZodOptional<ZodUnion<[…, …]>>; background-pattern: ZodOptional<ZodUnion<[…, …]>>; }, ZodTypeAny, "passthrough">, objectInputType<{ background-color: ZodOptional<ZodUnion<[…, …]>>; background-opacity: ZodOptional<ZodUnion<[…, …]>>; background-pattern: ZodOptional<ZodUnion<[…, …]>>; }, ZodTypeAny, "passthrough">>>; type: ZodLiteral<"background">; }, ZodTypeAny, "passthrough">)[][]
optionsMapRendererOptions{}
sources?Record<string, objectOutputType<{ attribution: ZodOptional<ZodString>; buffer: ZodOptional<ZodNumber>; cache: ZodOptional<ZodObject<{ enabled: ZodDefault<ZodBoolean>; ttl: ZodOptional<ZodNumber>; }, "strip", ZodTypeAny, { enabled: boolean; ttl?: number; }, { enabled?: boolean; ttl?: number; }>>; cluster: ZodOptional<ZodBoolean>; clusterMaxZoom: ZodOptional<ZodNumber>; clusterMinPoints: ZodOptional<ZodNumber>; clusterProperties: ZodOptional<ZodRecord<ZodString, ZodAny>>; clusterRadius: ZodOptional<ZodNumber>; data: ZodOptional<ZodAny>; fetchStrategy: ZodDefault<ZodEnum<["runtime", "build", "hybrid"]>>; generateId: ZodOptional<ZodBoolean>; lineMetrics: ZodOptional<ZodBoolean>; loading: ZodOptional<ZodObject<{ enabled: ZodDefault<ZodBoolean>; message: ZodOptional<ZodString>; showErrorOverlay: ZodDefault<ZodBoolean>; }, "strip", ZodTypeAny, { enabled: boolean; message?: string; showErrorOverlay: boolean; }, { enabled?: boolean; message?: string; showErrorOverlay?: boolean; }>>; prefetchedData: ZodOptional<ZodAny>; promoteId: ZodOptional<ZodUnion<[ZodString, ZodRecord<ZodString, ZodString>]>>; refresh: ZodOptional<ZodEffects<ZodObject<{ refreshInterval: ZodOptional<ZodNumber>; timestampField: ZodOptional<ZodString>; updateKey: ZodOptional<ZodString>; updateStrategy: ZodDefault<ZodEnum<…>>; windowDuration: ZodOptional<ZodNumber>; windowSize: ZodOptional<ZodNumber>; }, "strip", ZodTypeAny, { refreshInterval?: number; timestampField?: string; updateKey?: string; updateStrategy: "replace" | "merge" | "append-window"; windowDuration?: number; windowSize?: number; }, { refreshInterval?: number; timestampField?: string; updateKey?: string; updateStrategy?: "replace" | "merge" | "append-window"; windowDuration?: number; windowSize?: number; }>, { refreshInterval?: number; timestampField?: string; updateKey?: string; updateStrategy: "replace" | "merge" | "append-window"; windowDuration?: number; windowSize?: number; }, { refreshInterval?: number; timestampField?: string; updateKey?: string; updateStrategy?: "replace" | "merge" | "append-window"; windowDuration?: number; windowSize?: number; }>>; refreshInterval: ZodOptional<ZodNumber>; stream: ZodOptional<ZodObject<{ eventTypes: ZodOptional<ZodArray<ZodString, "many">>; protocols: ZodOptional<ZodUnion<[…, …]>>; reconnect: ZodDefault<ZodBoolean>; reconnectDelay: ZodDefault<ZodNumber>; reconnectMaxAttempts: ZodDefault<ZodNumber>; reconnectMaxDelay: ZodDefault<ZodNumber>; type: ZodEnum<["websocket", "sse"]>; url: ZodOptional<ZodString>; }, "strip", ZodTypeAny, { eventTypes?: string[]; protocols?: string | string[]; reconnect: boolean; reconnectDelay: number; reconnectMaxAttempts: number; reconnectMaxDelay: number; type: "websocket" | "sse"; url?: string; }, { eventTypes?: string[]; protocols?: string | string[]; reconnect?: boolean; reconnectDelay?: number; reconnectMaxAttempts?: number; reconnectMaxDelay?: number; type: "websocket" | "sse"; url?: string; }>>; tolerance: ZodOptional<ZodNumber>; type: ZodLiteral<"geojson">; updateKey: ZodOptional<ZodString>; updateStrategy: ZodOptional<ZodEnum<["replace", "merge", "append-window"]>>; url: ZodOptional<ZodString>; }, ZodTypeAny, "passthrough"> | objectOutputType<{ attribution: ZodOptional<ZodString>; bounds: ZodOptional<ZodTuple<[ZodNumber, ZodNumber, ZodNumber, ZodNumber], null>>; maxzoom: ZodOptional<ZodNumber>; minzoom: ZodOptional<ZodNumber>; promoteId: ZodOptional<ZodUnion<[ZodString, ZodRecord<ZodString, ZodString>]>>; scheme: ZodOptional<ZodEnum<["xyz", "tms"]>>; tiles: ZodOptional<ZodArray<ZodEffects<ZodString, string, string>, "many">>; type: ZodLiteral<"vector">; url: ZodOptional<ZodString>; volatile: ZodOptional<ZodBoolean>; }, ZodTypeAny, "passthrough"> | objectOutputType<{ attribution: ZodOptional<ZodString>; bounds: ZodOptional<ZodTuple<[ZodNumber, ZodNumber, ZodNumber, ZodNumber], null>>; maxzoom: ZodOptional<ZodNumber>; minzoom: ZodOptional<ZodNumber>; scheme: ZodOptional<ZodEnum<["xyz", "tms"]>>; tiles: ZodOptional<ZodArray<ZodEffects<ZodString, string, string>, "many">>; tileSize: ZodDefault<ZodNumber>; type: ZodLiteral<"raster">; url: ZodOptional<ZodString>; volatile: ZodOptional<ZodBoolean>; }, ZodTypeAny, "passthrough"> | objectOutputType<{ attribution: ZodOptional<ZodString>; bounds: ZodOptional<ZodTuple<[ZodNumber, ZodNumber, ZodNumber, ZodNumber], null>>; encoding: ZodDefault<ZodEnum<["terrarium", "mapbox", "custom"]>>; maxzoom: ZodOptional<ZodNumber>; minzoom: ZodOptional<ZodNumber>; tiles: ZodOptional<ZodArray<ZodEffects<ZodString, string, string>, "many">>; tileSize: ZodDefault<ZodNumber>; type: ZodLiteral<"raster-dem">; url: ZodOptional<ZodString>; volatile: ZodOptional<ZodBoolean>; }, ZodTypeAny, "passthrough"> | objectOutputType<{ coordinates: ZodTuple<[ZodTuple<[ZodNumber, ZodNumber], null>, ZodTuple<[ZodNumber, ZodNumber], null>, ZodTuple<[ZodNumber, ZodNumber], null>, ZodTuple<[ZodNumber, ZodNumber], null>], null>; type: ZodLiteral<"image">; url: ZodString; }, ZodTypeAny, "passthrough"> | objectOutputType<{ coordinates: ZodTuple<[ZodTuple<[ZodNumber, ZodNumber], null>, ZodTuple<[ZodNumber, ZodNumber], null>, ZodTuple<[ZodNumber, ZodNumber], null>, ZodTuple<[ZodNumber, ZodNumber], null>], null>; type: ZodLiteral<"video">; urls: ZodArray<ZodString, "many">; }, ZodTypeAny, "passthrough">>undefined

MapRenderer

addControls(config): void

Defined in: packages/core/src/renderer/map-renderer.ts:779

Add controls to the map

ParameterType
config{ attribution?: boolean | { compact?: boolean; customAttribution?: string | string[]; enabled?: boolean; position?: "top-left" | "top-right" | "bottom-left" | "bottom-right"; }; fullscreen?: boolean | { enabled: boolean; position?: "top-left" | "top-right" | "bottom-left" | "bottom-right"; }; geolocate?: boolean | { enabled: boolean; position?: "top-left" | "top-right" | "bottom-left" | "bottom-right"; }; globe?: boolean | { enabled: boolean; position?: "top-left" | "top-right" | "bottom-left" | "bottom-right"; }; navigation?: boolean | { enabled: boolean; position?: "top-left" | "top-right" | "bottom-left" | "bottom-right"; }; scale?: boolean | { enabled: boolean; position?: "top-left" | "top-right" | "bottom-left" | "bottom-right"; }; terrain?: boolean | { enabled: boolean; position?: "top-left" | "top-right" | "bottom-left" | "bottom-right"; }; }
config.attribution?boolean | { compact?: boolean; customAttribution?: string | string[]; enabled?: boolean; position?: "top-left" | "top-right" | "bottom-left" | "bottom-right"; }
config.fullscreen?boolean | { enabled: boolean; position?: "top-left" | "top-right" | "bottom-left" | "bottom-right"; }
config.geolocate?boolean | { enabled: boolean; position?: "top-left" | "top-right" | "bottom-left" | "bottom-right"; }
config.globe?boolean | { enabled: boolean; position?: "top-left" | "top-right" | "bottom-left" | "bottom-right"; }
config.navigation?boolean | { enabled: boolean; position?: "top-left" | "top-right" | "bottom-left" | "bottom-right"; }
config.scale?boolean | { enabled: boolean; position?: "top-left" | "top-right" | "bottom-left" | "bottom-right"; }
config.terrain?boolean | { enabled: boolean; position?: "top-left" | "top-right" | "bottom-left" | "bottom-right"; }

void

Called automatically on map load when a controls: config was passed via MapRendererOptions. Calling it manually marks controls as added so the automatic invocation is skipped (no double-add).


addLayer(layer): Promise<void>

Defined in: packages/core/src/renderer/map-renderer.ts:708

Add a layer to the map

ParameterType
layerobjectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<{ id: ZodString; layout: ZodOptional<ZodObject<{ }, "passthrough", ZodTypeAny, objectOutputType<{ }, ZodTypeAny, "passthrough">, objectInputType<{ }, ZodTypeAny, "passthrough">>>; metadata: ZodOptional<ZodRecord<ZodString, ZodAny>>; paint: ZodOptional<ZodObject<{ background-color: ZodOptional<ZodUnion<[ZodEffects<ZodString, string, string>, ZodType<…[], ZodTypeDef, …[]>]>>; background-opacity: ZodOptional<ZodUnion<[ZodNumber, ZodType<…[], ZodTypeDef, …[]>]>>; background-pattern: ZodOptional<ZodUnion<[ZodString, ZodType<…[], ZodTypeDef, …[]>]>>; }, "passthrough", ZodTypeAny, objectOutputType<{ background-color: ZodOptional<ZodUnion<[ZodEffects<…, …, …>, ZodType<…, …, …>]>>; background-opacity: ZodOptional<ZodUnion<[ZodNumber, ZodType<…, …, …>]>>; background-pattern: ZodOptional<ZodUnion<[ZodString, ZodType<…, …, …>]>>; }, ZodTypeAny, "passthrough">, objectInputType<{ background-color: ZodOptional<ZodUnion<[ZodEffects<…, …, …>, ZodType<…, …, …>]>>; background-opacity: ZodOptional<ZodUnion<[ZodNumber, ZodType<…, …, …>]>>; background-pattern: ZodOptional<ZodUnion<[ZodString, ZodType<…, …, …>]>>; }, ZodTypeAny, "passthrough">>>; type: ZodLiteral<"background">; }, ZodTypeAny, "passthrough">

Promise<void>


buildLegend(container, layers, config?): void

Defined in: packages/core/src/renderer/map-renderer.ts:792

Build legend in container

ParameterType
containerstring | HTMLElement
layers(objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<object & object, ZodTypeAny, "passthrough"> | objectOutputType<{ id: ZodString; layout: ZodOptional<ZodObject<{ }, "passthrough", ZodTypeAny, objectOutputType<{ }, ZodTypeAny, "passthrough">, objectInputType<{ }, ZodTypeAny, "passthrough">>>; metadata: ZodOptional<ZodRecord<ZodString, ZodAny>>; paint: ZodOptional<ZodObject<{ background-color: ZodOptional<ZodUnion<[ZodEffects<…, …, …>, ZodType<…, …, …>]>>; background-opacity: ZodOptional<ZodUnion<[ZodNumber, ZodType<…, …, …>]>>; background-pattern: ZodOptional<ZodUnion<[ZodString, ZodType<…, …, …>]>>; }, "passthrough", ZodTypeAny, objectOutputType<{ background-color: ZodOptional<ZodUnion<[…, …]>>; background-opacity: ZodOptional<ZodUnion<[…, …]>>; background-pattern: ZodOptional<ZodUnion<[…, …]>>; }, ZodTypeAny, "passthrough">, objectInputType<{ background-color: ZodOptional<ZodUnion<[…, …]>>; background-opacity: ZodOptional<ZodUnion<[…, …]>>; background-pattern: ZodOptional<ZodUnion<[…, …]>>; }, ZodTypeAny, "passthrough">>>; type: ZodLiteral<"background">; }, ZodTypeAny, "passthrough">)[]
config?{ collapsed: boolean; items?: object[]; position: "top-left" | "top-right" | "bottom-left" | "bottom-right"; title?: string; }
config.collapsed?boolean
config.items?object[]
config.position?"top-left" | "top-right" | "bottom-left" | "bottom-right"
config.title?string

void

Called automatically on map load when a legend: config was passed via MapRendererOptions. Calling it manually marks the legend as built so the automatic invocation is skipped (no double-build).


destroy(): void

Defined in: packages/core/src/renderer/map-renderer.ts:946

Destroy the map and clean up resources

void


getLegendBuilder(): LegendBuilder

Defined in: packages/core/src/renderer/map-renderer.ts:907

Get the legend builder instance

LegendBuilder


getMap(): maplibregl.Map

Defined in: packages/core/src/renderer/map-renderer.ts:694

Get the underlying MapLibre map instance

maplibregl.Map


isMapLoaded(): boolean

Defined in: packages/core/src/renderer/map-renderer.ts:701

Check if map is loaded

boolean


off<K>(event, callback): void

Defined in: packages/core/src/renderer/map-renderer.ts:924

Unregister an event listener

Type Parameter
K extends keyof MapRendererEvents
ParameterType
eventK
callbackFunction

void


on<K>(event, callback): void

Defined in: packages/core/src/renderer/map-renderer.ts:914

Register an event listener

Type Parameter
K extends keyof MapRendererEvents
ParameterType
eventK
callback(data) => void

void


removeLayer(layerId): void

Defined in: packages/core/src/renderer/map-renderer.ts:748

Remove a layer from the map

ParameterType
layerIdstring

void


setLayerVisibility(layerId, visible): void

Defined in: packages/core/src/renderer/map-renderer.ts:757

Set layer visibility

ParameterType
layerIdstring
visibleboolean

void


updateLayerData(layerId, data): void

Defined in: packages/core/src/renderer/map-renderer.ts:764

Update layer data

ParameterType
layerIdstring
dataGeoJSON

void


static fromModel(container, model, options?): MapRenderer

Defined in: packages/core/src/renderer/map-renderer.ts:280

Construct a renderer from the v2 internal model.

ParameterType
containerstring | HTMLElement
modelMapModel
optionsMapRendererOptions

MapRenderer

The model is the shape the emitter is written against (R30), and this is how the renderer consumes the same one. v0.5.0 keeps the v1 constructor as the compatibility surface — it is public API with external callers, and breaking it inside a minor is not on the table — so this factory reassembles the v1 arguments rather than the managers being rewritten onto new shapes.

<ml-map> does not call this — it derives the same arguments inline, so the component test double (which mocks MapRenderer as a bare function with no statics) keeps working. This factory is for callers that already hold a model. It differs from the inline path in one respect worth knowing: caller options win over the model’s controls/legend, so passing { controls: undefined } erases them.