Class Map
Hierarchy (View Summary)
Index
Constructors
Properties
Methods
Constructors
constructor
Methods
addControl
Adds a control to the map.
Parameters
- control: Control
The control instance to add.
Optionalposition: ControlPositionThe position of the control.
Returns this
- control: Control
addSplatModel
Adds a SplatModel visualization to the map.
Parameters
- splatModel: SplatModel
The SplatModel instance to add.
- cameraParams: CameraParams | null = null
optional pitch and bearing for camera.
Returns void
- splatModel: SplatModel
fitBounds
Moves the camera such that the provided bounds are visible.
Parameters
- lngLatBoundsLike: LngLatBoundsLike
The bounds to fit.
Returns void
- lngLatBoundsLike: LngLatBoundsLike
getAltitudeAt
Returns the current terrain exaggeration factor.
Parameters
- position: LngLatLike
LngLat position.
- callback: (altitude: number) => void
Function called with the position's altitude or NaN if position is invalid or basemap is VOID.
Returns void
- position: LngLatLike
getBasemap
getBearing
Returns the current bearing (rotation) of the map in degrees.
Returns number
The bearing in degrees.
getCenter
Returns the current center of the map.
Parameters
- callback: (center: LngLat) => void
Function called with the center position.
Returns void
- callback: (center: LngLat) => void
getFov
Returns the current field of view (FOV) of the map.
Returns number
The FOV in degrees.
getMaxPitch
Returns the maximum allowed pitch (tilt).
Returns number
The maximum pitch.
getMinPitch
Returns the minimum allowed pitch (tilt).
Returns number
The minimum pitch.
getPitch
Returns the current pitch (tilt) of the map in degrees.
Returns number
The pitch in degrees.
getZoom
Returns the current zoom level of the map.
Returns number
The zoom level.
jumpTo
Instantly moves the camera to the specified position and zoom.
Parameters
- options: CameraOptions
The camera options to jump to.
Returns void
- options: CameraOptions
off
- off<
EventType extends
| "load"
| "error"
| "click"
| "splatmodel:load"
| "splatmodel:error"
| "splatmodel:remove"
| "splatmodel:update"
| "splatmodel:mouseover"
| "splatmodel:mouseout"
| "splatmodel:click"
| "splatmodel:dragstart"
| "splatmodel:dragend"
| "resolution"
| "move"
| "moveend"
| "movestart",
>(
eventType: EventType,
handler: (
event:
| Extract<MapClickEvent, { type: EventType }>
| Extract<MapErrorEvent, { type: EventType }>
| Extract<MapModelResolutionEvent, { type: EventType }>
| Extract<MapLoadEvent, { type: EventType }>
| Extract<MapMoveEvent, { type: EventType }>
| Extract<MapMoveEndEvent, { type: EventType }>
| Extract<MapMoveStartEvent, { type: EventType }>
| Extract<MapSplatModelLoadEvent, { type: EventType }>
| Extract<MapSplatModelErrorEvent, { type: EventType }>
| Extract<MapSplatModelRemoveEvent, { type: EventType }>
| Extract<MapSplatModelUpdateEvent, { type: EventType }>
| Extract<MapSplatModelMouseOverEvent, { type: EventType }>
| Extract<MapSplatModelMouseOutEvent, { type: EventType }>
| Extract<MapSplatModelClickEvent, { type: EventType }>
| Extract<MapSplatModelDragStartEvent, { type: EventType }>
| Extract<MapSplatModelDragEndEvent, { type: EventType }>,
) => void,
): voidRemoves a listener for a specific event type.
Type Parameters
- EventType extends
| "load"
| "error"
| "click"
| "splatmodel:load"
| "splatmodel:error"
| "splatmodel:remove"
| "splatmodel:update"
| "splatmodel:mouseover"
| "splatmodel:mouseout"
| "splatmodel:click"
| "splatmodel:dragstart"
| "splatmodel:dragend"
| "resolution"
| "move"
| "moveend"
| "movestart"
Parameters
- eventType: EventType
The type of event to remove the listener from.
- handler: (
event:
| Extract<MapClickEvent, { type: EventType }>
| Extract<MapErrorEvent, { type: EventType }>
| Extract<MapModelResolutionEvent, { type: EventType }>
| Extract<MapLoadEvent, { type: EventType }>
| Extract<MapMoveEvent, { type: EventType }>
| Extract<MapMoveEndEvent, { type: EventType }>
| Extract<MapMoveStartEvent, { type: EventType }>
| Extract<MapSplatModelLoadEvent, { type: EventType }>
| Extract<MapSplatModelErrorEvent, { type: EventType }>
| Extract<MapSplatModelRemoveEvent, { type: EventType }>
| Extract<MapSplatModelUpdateEvent, { type: EventType }>
| Extract<MapSplatModelMouseOverEvent, { type: EventType }>
| Extract<MapSplatModelMouseOutEvent, { type: EventType }>
| Extract<MapSplatModelClickEvent, { type: EventType }>
| Extract<MapSplatModelDragStartEvent, { type: EventType }>
| Extract<MapSplatModelDragEndEvent, { type: EventType }>,
) => voidThe listener function to remove.
Returns void
- EventType extends
on
- on<
EventType extends
| "load"
| "error"
| "click"
| "splatmodel:load"
| "splatmodel:error"
| "splatmodel:remove"
| "splatmodel:update"
| "splatmodel:mouseover"
| "splatmodel:mouseout"
| "splatmodel:click"
| "splatmodel:dragstart"
| "splatmodel:dragend"
| "resolution"
| "move"
| "moveend"
| "movestart",
>(
eventType: EventType,
handler: (
event:
| Extract<MapClickEvent, { type: EventType }>
| Extract<MapErrorEvent, { type: EventType }>
| Extract<MapModelResolutionEvent, { type: EventType }>
| Extract<MapLoadEvent, { type: EventType }>
| Extract<MapMoveEvent, { type: EventType }>
| Extract<MapMoveEndEvent, { type: EventType }>
| Extract<MapMoveStartEvent, { type: EventType }>
| Extract<MapSplatModelLoadEvent, { type: EventType }>
| Extract<MapSplatModelErrorEvent, { type: EventType }>
| Extract<MapSplatModelRemoveEvent, { type: EventType }>
| Extract<MapSplatModelUpdateEvent, { type: EventType }>
| Extract<MapSplatModelMouseOverEvent, { type: EventType }>
| Extract<MapSplatModelMouseOutEvent, { type: EventType }>
| Extract<MapSplatModelClickEvent, { type: EventType }>
| Extract<MapSplatModelDragStartEvent, { type: EventType }>
| Extract<MapSplatModelDragEndEvent, { type: EventType }>,
) => void,
): voidAdds a listener for a specific event type.
Type Parameters
- EventType extends
| "load"
| "error"
| "click"
| "splatmodel:load"
| "splatmodel:error"
| "splatmodel:remove"
| "splatmodel:update"
| "splatmodel:mouseover"
| "splatmodel:mouseout"
| "splatmodel:click"
| "splatmodel:dragstart"
| "splatmodel:dragend"
| "resolution"
| "move"
| "moveend"
| "movestart"
Parameters
- eventType: EventType
The type of event to listen for.
- handler: (
event:
| Extract<MapClickEvent, { type: EventType }>
| Extract<MapErrorEvent, { type: EventType }>
| Extract<MapModelResolutionEvent, { type: EventType }>
| Extract<MapLoadEvent, { type: EventType }>
| Extract<MapMoveEvent, { type: EventType }>
| Extract<MapMoveEndEvent, { type: EventType }>
| Extract<MapMoveStartEvent, { type: EventType }>
| Extract<MapSplatModelLoadEvent, { type: EventType }>
| Extract<MapSplatModelErrorEvent, { type: EventType }>
| Extract<MapSplatModelRemoveEvent, { type: EventType }>
| Extract<MapSplatModelUpdateEvent, { type: EventType }>
| Extract<MapSplatModelMouseOverEvent, { type: EventType }>
| Extract<MapSplatModelMouseOutEvent, { type: EventType }>
| Extract<MapSplatModelClickEvent, { type: EventType }>
| Extract<MapSplatModelDragStartEvent, { type: EventType }>
| Extract<MapSplatModelDragEndEvent, { type: EventType }>,
) => voidThe function to call when the event is fired.
Returns void
- EventType extends
once
- once<
EventType extends
| "load"
| "error"
| "click"
| "splatmodel:load"
| "splatmodel:error"
| "splatmodel:remove"
| "splatmodel:update"
| "splatmodel:mouseover"
| "splatmodel:mouseout"
| "splatmodel:click"
| "splatmodel:dragstart"
| "splatmodel:dragend"
| "resolution"
| "move"
| "moveend"
| "movestart",
>(
eventType: EventType,
handler: (
event:
| Extract<MapClickEvent, { type: EventType }>
| Extract<MapErrorEvent, { type: EventType }>
| Extract<MapModelResolutionEvent, { type: EventType }>
| Extract<MapLoadEvent, { type: EventType }>
| Extract<MapMoveEvent, { type: EventType }>
| Extract<MapMoveEndEvent, { type: EventType }>
| Extract<MapMoveStartEvent, { type: EventType }>
| Extract<MapSplatModelLoadEvent, { type: EventType }>
| Extract<MapSplatModelErrorEvent, { type: EventType }>
| Extract<MapSplatModelRemoveEvent, { type: EventType }>
| Extract<MapSplatModelUpdateEvent, { type: EventType }>
| Extract<MapSplatModelMouseOverEvent, { type: EventType }>
| Extract<MapSplatModelMouseOutEvent, { type: EventType }>
| Extract<MapSplatModelClickEvent, { type: EventType }>
| Extract<MapSplatModelDragStartEvent, { type: EventType }>
| Extract<MapSplatModelDragEndEvent, { type: EventType }>,
) => void,
): voidAdds a listener for a specific event type that will be called only once.
Type Parameters
- EventType extends
| "load"
| "error"
| "click"
| "splatmodel:load"
| "splatmodel:error"
| "splatmodel:remove"
| "splatmodel:update"
| "splatmodel:mouseover"
| "splatmodel:mouseout"
| "splatmodel:click"
| "splatmodel:dragstart"
| "splatmodel:dragend"
| "resolution"
| "move"
| "moveend"
| "movestart"
Parameters
- eventType: EventType
The type of event to listen for.
- handler: (
event:
| Extract<MapClickEvent, { type: EventType }>
| Extract<MapErrorEvent, { type: EventType }>
| Extract<MapModelResolutionEvent, { type: EventType }>
| Extract<MapLoadEvent, { type: EventType }>
| Extract<MapMoveEvent, { type: EventType }>
| Extract<MapMoveEndEvent, { type: EventType }>
| Extract<MapMoveStartEvent, { type: EventType }>
| Extract<MapSplatModelLoadEvent, { type: EventType }>
| Extract<MapSplatModelErrorEvent, { type: EventType }>
| Extract<MapSplatModelRemoveEvent, { type: EventType }>
| Extract<MapSplatModelUpdateEvent, { type: EventType }>
| Extract<MapSplatModelMouseOverEvent, { type: EventType }>
| Extract<MapSplatModelMouseOutEvent, { type: EventType }>
| Extract<MapSplatModelClickEvent, { type: EventType }>
| Extract<MapSplatModelDragStartEvent, { type: EventType }>
| Extract<MapSplatModelDragEndEvent, { type: EventType }>,
) => voidThe function to call when the event is fired.
Returns void
- EventType extends
remove
Removes the map and cleans up all related resources.
Returns void
removeSplatModel
Removes a SplatModel visualization from the map.
Parameters
- splatModel: SplatModel
The SplatModel instance to remove.
Returns void
- splatModel: SplatModel
setBasemap
Changes the basemap.
Parameters
- basemap: ReferenceMapStyle
The new basemap identifier (e.g., 'satellite-v4').
Returns void
- basemap: ReferenceMapStyle
setBearing
Sets the bearing (rotation) of the map.
Parameters
- bearing: number
The new bearing in degrees.
Returns void
- bearing: number
setCenter
Sets the center position of the map.
Parameters
- center: LngLatLike
The new center position.
Returns void
- center: LngLatLike
setMaxPitch
Sets the maximum pitch (tilt) of the map.
Parameters
- pitch: number
The new maximum pitch, from 0 to 180.
Returns void
- pitch: number
setMinPitch
Sets the minimum pitch (tilt) of the map.
Parameters
- pitch: number
The new minimum pitch, from 0 to 180.
Returns void
- pitch: number
setModelResolution
Changes rendered model quality.
Parameters
- resolution: ModelResolutionType
sets render quality for models. QUALITY option might have impact on performance.
Returns void
- resolution: ModelResolutionType
setPitch
Sets the pitch (tilt) of the map.
Parameters
- pitch: number
The new pitch in degrees.
Returns void
- pitch: number
setPitchLocked
Locks or unlocks the current pitch of the map.
Parameters
- locked: boolean
Whether to lock the pitch.
Returns void
- locked: boolean
setZoom
Sets the zoom level of the map.
Parameters
- zoom: number
The new zoom level.
Returns void
- zoom: number
zoomIn
Zooms in by one level.
Returns void
zoomOut
Zooms out by one level.
Returns void
The main Map class for creating and controlling a MapTiler WebGPU interactive map.
Example