MapRenderer
Defined in: packages/core/src/renderer/map-renderer.ts:231
Main class for rendering maps from configuration
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new MapRenderer(
container,config,layers?,options?,sources?):MapRenderer
Defined in: packages/core/src/renderer/map-renderer.ts:294
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
container | string | HTMLElement | undefined |
config | objectOutputType | undefined |
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">)[] | [] |
options | MapRendererOptions | {} |
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 |
Returns
Section titled “Returns”MapRenderer
Methods
Section titled “Methods”addControls()
Section titled “addControls()”addControls(
config):void
Defined in: packages/core/src/renderer/map-renderer.ts:779
Add controls to the map
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
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"; } |
Returns
Section titled “Returns”void
Remarks
Section titled “Remarks”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()
Section titled “addLayer()”addLayer(
layer):Promise<void>
Defined in: packages/core/src/renderer/map-renderer.ts:708
Add a layer to the map
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
layer | 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<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"> |
Returns
Section titled “Returns”Promise<void>
buildLegend()
Section titled “buildLegend()”buildLegend(
container,layers,config?):void
Defined in: packages/core/src/renderer/map-renderer.ts:792
Build legend in container
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
container | string | 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 |
Returns
Section titled “Returns”void
Remarks
Section titled “Remarks”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()
Section titled “destroy()”destroy():
void
Defined in: packages/core/src/renderer/map-renderer.ts:946
Destroy the map and clean up resources
Returns
Section titled “Returns”void
getLegendBuilder()
Section titled “getLegendBuilder()”getLegendBuilder():
LegendBuilder
Defined in: packages/core/src/renderer/map-renderer.ts:907
Get the legend builder instance
Returns
Section titled “Returns”getMap()
Section titled “getMap()”getMap():
maplibregl.Map
Defined in: packages/core/src/renderer/map-renderer.ts:694
Get the underlying MapLibre map instance
Returns
Section titled “Returns”isMapLoaded()
Section titled “isMapLoaded()”isMapLoaded():
boolean
Defined in: packages/core/src/renderer/map-renderer.ts:701
Check if map is loaded
Returns
Section titled “Returns”boolean
off<
K>(event,callback):void
Defined in: packages/core/src/renderer/map-renderer.ts:924
Unregister an event listener
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
K extends keyof MapRendererEvents |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
event | K |
callback | Function |
Returns
Section titled “Returns”void
on<
K>(event,callback):void
Defined in: packages/core/src/renderer/map-renderer.ts:914
Register an event listener
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
K extends keyof MapRendererEvents |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
event | K |
callback | (data) => void |
Returns
Section titled “Returns”void
removeLayer()
Section titled “removeLayer()”removeLayer(
layerId):void
Defined in: packages/core/src/renderer/map-renderer.ts:748
Remove a layer from the map
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
layerId | string |
Returns
Section titled “Returns”void
setLayerVisibility()
Section titled “setLayerVisibility()”setLayerVisibility(
layerId,visible):void
Defined in: packages/core/src/renderer/map-renderer.ts:757
Set layer visibility
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
layerId | string |
visible | boolean |
Returns
Section titled “Returns”void
updateLayerData()
Section titled “updateLayerData()”updateLayerData(
layerId,data):void
Defined in: packages/core/src/renderer/map-renderer.ts:764
Update layer data
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
layerId | string |
data | GeoJSON |
Returns
Section titled “Returns”void
fromModel()
Section titled “fromModel()”
staticfromModel(container,model,options?):MapRenderer
Defined in: packages/core/src/renderer/map-renderer.ts:280
Construct a renderer from the v2 internal model.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
container | string | HTMLElement |
model | MapModel |
options | MapRendererOptions |
Returns
Section titled “Returns”MapRenderer
Remarks
Section titled “Remarks”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.