WemapMap
Class: WemapMap
A thin, opinionated wrapper around a maplibre-gl Map for Wemap livemaps.
It owns the underlying maplibre instance (created from options.container)
and adds first-class helpers for camera control, event subscription, and
multi-level / indoor display via setLevel.
The raw maplibre map remains available through maplibre for anything the wrapper does not cover.
Requires core.init() from @wemap/core beforehand — map style, bounds, zoom
range, and indoor settings are read from the parsed livemap snippet.
Pass any WemapMapOptions field in the constructor to override them.
Implements
Constructors
Constructor
new WemapMap(
options):WemapMap
Parameters
options
Returns
WemapMap
Properties
maplibre
readonlymaplibre:Map$1
The underlying maplibre-gl map instance.
Escape hatch for anything this wrapper doesn't cover. Not covered by
semver: the maplibre-gl version and this accessor may change in any minor
release, so code written directly against .maplibre can break without a
major version bump. Prefer the wrapper API wherever one exists.
Methods
addControl()
addControl(
control,position?):this
Add a maplibre control to the map (e.g. LevelControl).
Thin passthrough to the underlying maplibre addControl.
Parameters
control
position?
Returns
this
addLayer()
addLayer(
layer,options?):this
Add a layer to the style, optionally wiring it into level management.
Safe to call before the style has loaded. When the style is already loaded
(e.g. after whenReady), the layer is added synchronously. Adding the
layer is a no-op if its id already exists. Use { indoor: true } for layers
whose features carry a level so they follow setLevel.
map.addSource('my-src', { type: 'geojson', data });
map.addLayer({ id: 'my-rooms', type: 'fill', source: 'my-src' }, { indoor: true });
Parameters
layer
The layer to add.
options?
AddLayerOptions = {}
Returns
this
addSource()
addSource(
id,source):this
Add a source to the style. Safe to call before the style has loaded — the source is added as soon as the style is ready. When the style is already loaded (e.g. after whenReady), the source is added synchronously. No-op if the id already exists.
Parameters
id
string
Unique source id.
source
SourceSpecification
The source specification.
Returns
this
clearSearch()
clearSearch():
this
Undo the highlight/filter applied by search when
interaction.autoHighlightSearch is on: clear the highlight and show all
pinpoints again. The current selection is left intact.
Returns
this
easeTo()
easeTo(
options):this
Animate the camera to a new center/zoom with a smooth transition.
Parameters
options
Returns
this
filterPois()
filterPois(
ids):this
Restrict default POI layers to the given pinpoint ids.
An empty array is equivalent to hideAllPois.
Parameters
ids
number[]
Returns
this
fitBounds()
fitBounds(
bounds,options?):this
Pan and zoom the map to contain the given bounds.
Parameters
bounds
BoundingBox
options?
Returns
this
flyTo()
flyTo(
options):this
Animate the camera to a new center/zoom with an arcing motion.
Parameters
options
Returns
this
getBounds()
getBounds():
BoundingBox
The current viewport bounds.
Returns
BoundingBox
Implementation of
getCenter()
getCenter():
Coordinates
The current map center.
Returns
Implementation of
getCurrentBuilding()
getCurrentBuilding():
Building|null
The building nearest the viewport center, or null when indoor is disabled
in the snippet, zoom is below indoor.minZoom, or no building is in view.
Returns
Building | null
getLevel()
getLevel():
number|null
The currently displayed level, or null when none has been set.
Returns
number | null
Implementation of
getPoiFilter()
getPoiFilter():
number[] |null
Read the current POI visibility filter.
null— no filter, all pinpoints shown (minus highlight/selected excludes).number[]— whitelist; an empty array means all hidden.
Returns
number[] | null
getPoiHighlighted()
getPoiHighlighted():
number[]
Returns
number[]
getPoiSelected()
getPoiSelected():
number[]
Returns
number[]
getViewportPinpoints()
getViewportPinpoints():
Pinpoint[]
The API pinpoints currently inside the viewport and matching the active level, read synchronously from the loaded set. Pull this after whenReady for a deterministic first paint instead of waiting for the first onViewportPinpointsChange emit.
Returns
Pinpoint[]
getZoom()
getZoom():
number
The current zoom level.
Returns
number
Implementation of
hideAllPois()
hideAllPois():
this
Hide all pinpoints on default layers.
Returns
this
off()
Call Signature
off<
T>(type,layer,listener):this
Type Parameters
T
T extends keyof MapLayerEventType
Parameters
type
T
layer
string | string[]
listener
(ev) => void
Returns
this
Implementation of
Call Signature
off<
T>(type,listener):this
Type Parameters
T
T extends keyof MapEventType
Parameters
type
T
listener
(ev) => void
Returns
this
Implementation of
MapViewport.off
Call Signature
off(
type,listener):this
Parameters
type
"load" | "moveend"
listener
() => void
Returns
this
Implementation of
MapViewport.off
on()
Call Signature
on<
T>(type,layer,listener):this
Type Parameters
T
T extends keyof MapLayerEventType
Parameters
type
T
layer
string | string[]
listener
(ev) => void
Returns
this
Implementation of
Call Signature
on<
T>(type,listener):this
Type Parameters
T
T extends keyof MapEventType
Parameters
type
T