Skip to content

Documentation / @geoverse/core-libre / GMap

Class: GMap ​

Defined in: packages/core-libre/src/map/gmap.ts:87

GeoVerse Libre 地图容器,继承自 maplibregl.Map。

相对原生 Map 的增强:

  • 内置标准底图与 setBase 切换(切换后自动重装本库管理的图层)
  • style 异步加载的就绪门控(whenReady / isReady):图层在样式就绪后才安装
  • 地图级指针事件统一派发为要素级 click / mouseover / mouseout
  • 与 core 对齐的若干便捷方法(坐标一律 WGS-84 经纬度)

注:原生 getCenter/setCenter/getZoom/setZoom/panTo/getBounds 均已是 WGS-84/经纬度语义,直接复用,与 core 心智一致。

Extends ​

  • Map$1

Constructors ​

Constructor ​

ts
new GMap(opts?): GMap;

Defined in: packages/core-libre/src/map/gmap.ts:103

Parameters ​

opts? ​

GMapOptions = {}

Returns ​

GMap

Overrides ​

ts
MaplibreMap.constructor

Properties ​

_anisotropicFilterPitch ​

ts
_anisotropicFilterPitch: number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11410

Inherited from ​

ts
MaplibreMap._anisotropicFilterPitch

_bearingSnap ​

ts
_bearingSnap: number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8555

Inherited from ​

ts
MaplibreMap._bearingSnap

_canvas ​

ts
_canvas: HTMLCanvasElement;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11403

Inherited from ​

ts
MaplibreMap._canvas

_canvasContainer ​

ts
_canvasContainer: HTMLElement;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11393

Inherited from ​

ts
MaplibreMap._canvasContainer

_canvasContextAttributes ​

ts
_canvasContextAttributes: WebGLContextAttributesWithType;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11416

Inherited from ​

ts
MaplibreMap._canvasContextAttributes

_centerClampedToGround ​

ts
_centerClampedToGround: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8606

Internal

If true, the elevation of the center point will automatically be set to the terrain elevation (or zero if terrain is not enabled). If false, the elevation of the center point will default to sea level and will not automatically update. Defaults to true. Needs to be set to false to keep the camera above ground when pitch > 90 degrees.

Inherited from ​

ts
MaplibreMap._centerClampedToGround

_clickTolerance ​

ts
_clickTolerance: number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11433

Inherited from ​

ts
MaplibreMap._clickTolerance

_collectResourceTiming ​

ts
_collectResourceTiming: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11423

Inherited from ​

ts
MaplibreMap._collectResourceTiming

_container ​

ts
_container: HTMLElement;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11392

Inherited from ​

ts
MaplibreMap._container

_contextLost ​

ts
_contextLost: (event) => void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13125

Parameters ​

event ​

any

Returns ​

void

Inherited from ​

ts
MaplibreMap._contextLost

_contextRestored ​

ts
_contextRestored: (event) => void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13126

Parameters ​

event ​

any

Returns ​

void

Inherited from ​

ts
MaplibreMap._contextRestored

_controlContainer ​

ts
_controlContainer: HTMLElement;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11394

Inherited from ​

ts
MaplibreMap._controlContainer

_controlPositions ​

ts
_controlPositions: Partial<Record<ControlPosition, HTMLElement>>;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11395

Inherited from ​

ts
MaplibreMap._controlPositions

_controls ​

ts
_controls: IControl[];

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11425

Inherited from ​

ts
MaplibreMap._controls

_crossFadingFactor ​

ts
_crossFadingFactor: number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11422

Inherited from ​

ts
MaplibreMap._crossFadingFactor

_crossSourceCollisions ​

ts
_crossSourceCollisions: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11421

Inherited from ​

ts
MaplibreMap._crossSourceCollisions

_delegatedListeners ​

ts
_delegatedListeners: Record<string, DelegatedListener[]>;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11419

Inherited from ​

ts
MaplibreMap._delegatedListeners

_diffStyleRequest ​

ts
_diffStyleRequest: AbortController;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11432

Inherited from ​

ts
MaplibreMap._diffStyleRequest

_easeFrameId ​

ts
_easeFrameId: number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8565

Inherited from ​

ts
MaplibreMap._easeFrameId

_easeId ​

ts
_easeId: string | void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8562

Inherited from ​

ts
MaplibreMap._easeId

_easeOptions ​

ts
_easeOptions: {
  duration?: number;
  easing?: (_) => number;
};

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8558

duration? ​

ts
optional duration?: number;

easing? ​

ts
optional easing?: (_) => number;
Parameters ​
_ ​

number

Returns ​

number

Inherited from ​

ts
MaplibreMap._easeOptions

_easeStart ​

ts
_easeStart: number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8557

Inherited from ​

ts
MaplibreMap._easeStart

_elevationCenter ​

ts
_elevationCenter: LngLat;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8570

Internal

holds the geographical coordinate of the target

Inherited from ​

ts
MaplibreMap._elevationCenter

_elevationFreeze ​

ts
_elevationFreeze: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8588

Internal

Saves the current state of the elevation freeze - this is used during map movement to prevent "rocky" camera movement.

Inherited from ​

ts
MaplibreMap._elevationFreeze

_elevationStart ​

ts
_elevationStart: number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8583

Internal

holds the start altitude value, = center elevation before animation begins this value will recalculated during flight in respect of changing _elevationTarget values, so the linear interpolation between start and target keeps smooth and without jumps.

Inherited from ​

ts
MaplibreMap._elevationStart

_elevationTarget ​

ts
_elevationTarget: number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8576

Internal

holds the targ altitude value, = center elevation of the target. This value may changes during flight, because new terrain-tiles loads during flight.

Inherited from ​

ts
MaplibreMap._elevationTarget

_eventedParent ​

ts
_eventedParent: Evented;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:827

Inherited from ​

ts
MaplibreMap._eventedParent

_eventedParentData ​

ts
_eventedParentData: any;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:828

Inherited from ​

ts
MaplibreMap._eventedParentData

_fadeDuration ​

ts
_fadeDuration: number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11420

Inherited from ​

ts
MaplibreMap._fadeDuration

_frameRequest ​

ts
_frameRequest: AbortController;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11406

Inherited from ​

ts
MaplibreMap._frameRequest

_fullyLoaded ​

ts
_fullyLoaded: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11413

Inherited from ​

ts
MaplibreMap._fullyLoaded

_hash ​

ts
_hash: Hash;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11418

Inherited from ​

ts
MaplibreMap._hash

_idleTriggered ​

ts
_idleTriggered: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11412

Inherited from ​

ts
MaplibreMap._idleTriggered

_imageQueueHandle ​

ts
_imageQueueHandle: number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11452

Internal

image queue throttling handle. To be used later when clean up

Inherited from ​

ts
MaplibreMap._imageQueueHandle

_interactive ​

ts
_interactive: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11396

Inherited from ​

ts
MaplibreMap._interactive

_listeners ​

ts
_listeners: Listeners;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:825

Inherited from ​

ts
MaplibreMap._listeners

_loaded ​

ts
_loaded: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11411

Inherited from ​

ts
MaplibreMap._loaded

_locale ​

ts
_locale: Record<string, string>;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11430

Inherited from ​

ts
MaplibreMap._locale

_localIdeographFontFamily ​

ts
_localIdeographFontFamily: string | false;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11427

Inherited from ​

ts
MaplibreMap._localIdeographFontFamily

_lostContextStyle ​

ts
_lostContextStyle: LostContextStyle;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11457

Internal

Used to store the previous style and images when a context loss occurs, so they can be restored.

Inherited from ​

ts
MaplibreMap._lostContextStyle

_mapId ​

ts
_mapId: number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11426

Inherited from ​

ts
MaplibreMap._mapId

_maxCanvasSize ​

ts
_maxCanvasSize: [number, number];

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11435

Inherited from ​

ts
MaplibreMap._maxCanvasSize

_maxTileCacheSize ​

ts
_maxTileCacheSize: number | null;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11404

Inherited from ​

ts
MaplibreMap._maxTileCacheSize

_maxTileCacheZoomLevels ​

ts
_maxTileCacheZoomLevels: number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11405

Inherited from ​

ts
MaplibreMap._maxTileCacheZoomLevels

_moving ​

ts
_moving: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8549

Inherited from ​

ts
MaplibreMap._moving

_onEaseEnd ​

ts
_onEaseEnd: (easeId?) => void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8564

Parameters ​

easeId? ​

string

Returns ​

void

Inherited from ​

ts
MaplibreMap._onEaseEnd

_onEaseFrame ​

ts
_onEaseFrame: (_) => void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8563

Parameters ​

_ ​

number

Returns ​

void

Inherited from ​

ts
MaplibreMap._onEaseFrame

_oneTimeListeners ​

ts
_oneTimeListeners: Listeners;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:826

Inherited from ​

ts
MaplibreMap._oneTimeListeners

_onMapScroll ​

ts
_onMapScroll: (event) => boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13127

Parameters ​

event ​

any

Returns ​

boolean

Inherited from ​

ts
MaplibreMap._onMapScroll

_onWindowOnline ​

ts
_onWindowOnline: () => void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13197

Returns ​

void

Inherited from ​

ts
MaplibreMap._onWindowOnline

_overridePixelRatio ​

ts
_overridePixelRatio: number | null | undefined;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11434

Inherited from ​

ts
MaplibreMap._overridePixelRatio

_padding ​

ts
_padding: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8554

Inherited from ​

ts
MaplibreMap._padding

_pitching ​

ts
_pitching: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8552

Inherited from ​

ts
MaplibreMap._pitching

_placementDirty ​

ts
_placementDirty: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11409

Inherited from ​

ts
MaplibreMap._placementDirty

_refreshExpiredTiles ​

ts
_refreshExpiredTiles: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11417

Inherited from ​

ts
MaplibreMap._refreshExpiredTiles

_removed ​

ts
_removed: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11431

Inherited from ​

ts
MaplibreMap._removed

_renderFrameCallback ​

ts
_renderFrameCallback: () => void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:9197

Returns ​

void

Inherited from ​

ts
MaplibreMap._renderFrameCallback

_renderTaskQueue ​

ts
_renderTaskQueue: TaskQueue;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11424

Inherited from ​

ts
MaplibreMap._renderTaskQueue

_repaint ​

ts
_repaint: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11401

Inherited from ​

ts
MaplibreMap._repaint

_requestedCameraState? ​

ts
optional _requestedCameraState?: ITransform;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8593

Internal

Used to track accumulated changes during continuous interaction

Inherited from ​

ts
MaplibreMap._requestedCameraState

_requestManager ​

ts
_requestManager: RequestManager;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11429

Inherited from ​

ts
MaplibreMap._requestManager

_resizeObserver ​

ts
_resizeObserver: ResizeObserver;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11415

Inherited from ​

ts
MaplibreMap._resizeObserver

_rolling ​

ts
_rolling: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8553

Inherited from ​

ts
MaplibreMap._rolling

_rotating ​

ts
_rotating: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8551

Inherited from ​

ts
MaplibreMap._rotating

_showCollisionBoxes ​

ts
_showCollisionBoxes: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11398

Inherited from ​

ts
MaplibreMap._showCollisionBoxes

_showOverdrawInspector ​

ts
_showOverdrawInspector: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11400

Inherited from ​

ts
MaplibreMap._showOverdrawInspector

_showPadding ​

ts
_showPadding: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11399

Inherited from ​

ts
MaplibreMap._showPadding

_showTileBoundaries ​

ts
_showTileBoundaries: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11397

Inherited from ​

ts
MaplibreMap._showTileBoundaries

_sourcesDirty ​

ts
_sourcesDirty: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11408

Inherited from ​

ts
MaplibreMap._sourcesDirty

_styleDirty ​

ts
_styleDirty: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11407

Inherited from ​

ts
MaplibreMap._styleDirty

_terrainDataCallback ​

ts
_terrainDataCallback: (e) => void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11439

Parameters ​

e ​

MapSourceDataEvent | MapStyleDataEvent

Returns ​

void

Inherited from ​

ts
MaplibreMap._terrainDataCallback

_trackResize ​

ts
_trackResize: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11414

Inherited from ​

ts
MaplibreMap._trackResize

_validateStyle ​

ts
_validateStyle: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11428

Inherited from ​

ts
MaplibreMap._validateStyle

_vertices ​

ts
_vertices: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11402

Inherited from ​

ts
MaplibreMap._vertices

_zooming ​

ts
_zooming: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8550

Inherited from ​

ts
MaplibreMap._zooming

_zoomLevelsToOverscale ​

ts
_zoomLevelsToOverscale: number | undefined;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11441

Internal

Inherited from ​

ts
MaplibreMap._zoomLevelsToOverscale

_zoomSnap ​

ts
_zoomSnap: number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8556

Inherited from ​

ts
MaplibreMap._zoomSnap

boxZoom ​

ts
boxZoom: BoxZoomHandler;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11467

The map's BoxZoomHandler, which implements zooming using a drag gesture with the Shift key pressed. Find more details and examples using boxZoom in the BoxZoomHandler section.

Inherited from ​

ts
MaplibreMap.boxZoom

cameraHelper ​

ts
cameraHelper: ICameraHelper;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8546

Inherited from ​

ts
MaplibreMap.cameraHelper

cancelPendingTileRequestsWhileZooming ​

ts
cancelPendingTileRequestsWhileZooming: boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11510

The map's property which determines whether to cancel, or retain, tiles from the current viewport which are still loading but which belong to a farther (smaller) zoom level than the current one.

  • If true, when zooming in, tiles which didn't manage to load for previous zoom levels will become canceled. This might save some computing resources for slower devices, but the map details might appear more abruptly at the end of the zoom.
  • If false, when zooming in, the previous zoom level(s) tiles will progressively appear, giving a smoother map details experience. However, more tiles will be rendered in a short period of time.

Default Value ​

ts
true

Inherited from ​

ts
MaplibreMap.cancelPendingTileRequestsWhileZooming

cooperativeGestures ​

ts
cooperativeGestures: CooperativeGesturesHandler;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11503

The map's CooperativeGesturesHandler, which allows the user to see cooperative gesture info when user tries to zoom in/out. Find more details and examples using cooperativeGestures in the CooperativeGesturesHandler section.

Inherited from ​

ts
MaplibreMap.cooperativeGestures

doubleClickZoom ​

ts
doubleClickZoom: DoubleClickZoomHandler;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11488

The map's DoubleClickZoomHandler, which allows the user to zoom by double clicking. Find more details and examples using doubleClickZoom in the DoubleClickZoomHandler section.

Inherited from ​

ts
MaplibreMap.doubleClickZoom

dragPan ​

ts
dragPan: DragPanHandler;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11478

The map's DragPanHandler, which implements dragging the map with a mouse or touch gesture. Find more details and examples using dragPan in the DragPanHandler section.

Inherited from ​

ts
MaplibreMap.dragPan

dragRotate ​

ts
dragRotate: DragRotateHandler;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11473

The map's DragRotateHandler, which implements rotating the map while dragging with the right mouse button or with the Control key pressed. Find more details and examples using dragRotate in the DragRotateHandler section.

Inherited from ​

ts
MaplibreMap.dragRotate

handlers ​

ts
handlers: HandlerManager;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11391

Inherited from ​

ts
MaplibreMap.handlers

keyboard ​

ts
keyboard: KeyboardHandler;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11483

The map's KeyboardHandler, which allows the user to zoom, rotate, and pan the map using keyboard shortcuts. Find more details and examples using keyboard in the KeyboardHandler section.

Inherited from ​

ts
MaplibreMap.keyboard

painter ​

ts
painter: Painter;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11390

Inherited from ​

ts
MaplibreMap.painter

scrollZoom ​

ts
scrollZoom: ScrollZoomHandler;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11462

The map's ScrollZoomHandler, which implements zooming in and out with a scroll wheel or trackpad. Find more details and examples using scrollZoom in the ScrollZoomHandler section.

Inherited from ​

ts
MaplibreMap.scrollZoom

style ​

ts
style: Style;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11389

Inherited from ​

ts
MaplibreMap.style

terrain ​

ts
terrain: Terrain;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8547

Inherited from ​

ts
MaplibreMap.terrain

touchPitch ​

ts
touchPitch: TwoFingersTouchPitchHandler;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11498

The map's TwoFingersTouchPitchHandler, which allows the user to pitch the map with touch gestures. Find more details and examples using touchPitch in the TwoFingersTouchPitchHandler section.

Inherited from ​

ts
MaplibreMap.touchPitch

touchZoomRotate ​

ts
touchZoomRotate: TwoFingersTouchZoomRotateHandler;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11493

The map's TwoFingersTouchZoomRotateHandler, which allows the user to zoom or rotate the map with touch gestures. Find more details and examples using touchZoomRotate in the TwoFingersTouchZoomRotateHandler section.

Inherited from ​

ts
MaplibreMap.touchZoomRotate

transform ​

ts
transform: ITransform;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8545

Inherited from ​

ts
MaplibreMap.transform

transformCameraUpdate ​

ts
transformCameraUpdate: CameraUpdateTransformFunction | null;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8598

A callback used to defer camera updates or apply arbitrary constraints. If specified, this Camera instance can be used as a stateless component in React etc.

Inherited from ​

ts
MaplibreMap.transformCameraUpdate

transformConstrain ​

ts
transformConstrain: TransformConstrainFunction | null;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11515

The map transform's callback that overrides the default constrain function.

Default Value ​

ts
null

Inherited from ​

ts
MaplibreMap.transformConstrain

Accessors ​

_ownerWindow ​

Get Signature ​

ts
get _ownerWindow(): Window & typeof globalThis;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11447

Internal

The window that owns the map container element, for cross-window support. Returns typeof window to include global constructors like ResizeObserver.

Returns ​

Window & typeof globalThis

Inherited from ​

ts
MaplibreMap._ownerWindow

repaint ​

Get Signature ​

ts
get repaint(): boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13240

Gets and sets a Boolean indicating whether the map will continuously repaint. This information is useful for analyzing performance.

Returns ​

boolean

Set Signature ​

ts
set repaint(value): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13241

Parameters ​
value ​

boolean

Returns ​

void

Inherited from ​

ts
MaplibreMap.repaint

showCollisionBoxes ​

Get Signature ​

ts
get showCollisionBoxes(): boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13225

Gets and sets a Boolean indicating whether the map will render boxes around all symbols in the data source, revealing which symbols were rendered or which were hidden due to collisions. This information is useful for debugging.

Returns ​

boolean

Set Signature ​

ts
set showCollisionBoxes(value): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13226

Parameters ​
value ​

boolean

Returns ​

void

Inherited from ​

ts
MaplibreMap.showCollisionBoxes

showOverdrawInspector ​

Get Signature ​

ts
get showOverdrawInspector(): boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13234

Gets and sets a Boolean indicating whether the map should color-code each fragment to show how many times it has been shaded. White fragments have been shaded 8 or more times. Black fragments have been shaded 0 times. This information is useful for debugging.

Returns ​

boolean

Set Signature ​

ts
set showOverdrawInspector(value): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13235

Parameters ​
value ​

boolean

Returns ​

void

Inherited from ​

ts
MaplibreMap.showOverdrawInspector

showPadding ​

Get Signature ​

ts
get showPadding(): boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13217

Gets and sets a Boolean indicating whether the map will visualize the padding offsets.

Returns ​

boolean

Set Signature ​

ts
set showPadding(value): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13218

Parameters ​
value ​

boolean

Returns ​

void

Inherited from ​

ts
MaplibreMap.showPadding

showTileBoundaries ​

Get Signature ​

ts
get showTileBoundaries(): boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13211

Gets and sets a Boolean indicating whether the map will render an outline around each tile and the tile ID. These tile boundaries are useful for debugging.

The uncompressed file size of the first vector source is drawn in the top left corner of each tile, next to the tile ID.

Example ​
ts
map.showTileBoundaries = true;
Returns ​

boolean

Set Signature ​

ts
set showTileBoundaries(value): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13212

Parameters ​
value ​

boolean

Returns ​

void

Inherited from ​

ts
MaplibreMap.showTileBoundaries

version ​

Get Signature ​

ts
get version(): string;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13248

Returns the package version of the library

Returns ​

string

Package version of the library

Inherited from ​

ts
MaplibreMap.version

vertices ​

Get Signature ​

ts
get vertices(): boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13242

Returns ​

boolean

Set Signature ​

ts
set vertices(value): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13243

Parameters ​
value ​

boolean

Returns ​

void

Inherited from ​

ts
MaplibreMap.vertices

Methods ​

_afterEase() ​

ts
_afterEase(eventData?, easeId?): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:9148

Parameters ​

eventData? ​

any

easeId? ​

string

Returns ​

void

Inherited from ​

ts
MaplibreMap._afterEase

_applyUpdatedTransform() ​

ts
_applyUpdatedTransform(tr): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:9146

Internal

Called after the camera is done being manipulated.

Parameters ​

tr ​

ITransform

the requested camera end state If the camera is inside terrain, it gets elevated. Call transformCameraUpdate if present, and then apply the "approved" changes.

Returns ​

void

Inherited from ​

ts
MaplibreMap._applyUpdatedTransform

_cameraForBoxAndBearing() ​

ts
_cameraForBoxAndBearing(
   p0, 
   p1, 
   bearing, 
   options?): CenterZoomBearing | undefined;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8971

Internal

Calculate the center of these two points in the viewport and use the highest zoom level up to and including Map.getMaxZoom that fits the AABB defined by these points in the viewport at the specified bearing.

Parameters ​

p0 ​

LngLatLike

First point

p1 ​

LngLatLike

Second point

bearing ​

number

Desired map bearing at end of animation, in degrees

options? ​

CameraForBoundsOptions

the camera options

Returns ​

CenterZoomBearing | undefined

If map is able to fit to provided bounds, returns center, zoom, and bearing. If map is unable to fit, method will warn and return undefined.

Example ​

ts
let p0 = [-79, 43];
let p1 = [-73, 45];
let bearing = 90;
let newCameraTransform = map._cameraForBoxAndBearing(p0, p1, bearing, {
  padding: {top: 10, bottom:25, left: 15, right: 5}
});

Inherited from ​

ts
MaplibreMap._cameraForBoxAndBearing

_cancelRenderFrame() ​

ts
_cancelRenderFrame(id): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13154

Parameters ​

id ​

number

Returns ​

void

Inherited from ​

ts
MaplibreMap._cancelRenderFrame

_containerDimensions() ​

ts
_containerDimensions(): number[];

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13108

Returns ​

number[]

Inherited from ​

ts
MaplibreMap._containerDimensions

_createDelegatedListener() ​

ts
_createDelegatedListener(
   type, 
   layerIds, 
   listener): DelegatedListener;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11920

Parameters ​

type ​

string

layerIds ​

string[]

listener ​

Listener

Returns ​

DelegatedListener

Inherited from ​

ts
MaplibreMap._createDelegatedListener

_diffStyle() ​

ts
_diffStyle(style, options?): Promise<void>;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12300

Parameters ​

style ​

string | StyleSpecification

options? ​

StyleSwapOptions & StyleOptions

Returns ​

Promise<void>

Inherited from ​

ts
MaplibreMap._diffStyle

_ease() ​

ts
_ease(
   frame, 
   finish, 
   options): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:9192

Parameters ​

frame ​

(_) => void

finish ​

() => void

options ​
animate? ​

boolean

duration? ​

number

easing? ​

(_) => number

Returns ​

void

Inherited from ​

ts
MaplibreMap._ease

_elevateCameraIfInsideTerrain() ​

ts
_elevateCameraIfInsideTerrain(tr): {
  pitch?: number;
  zoom?: number;
};

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:9135

Internal

Checks the given transform for the camera being below terrain surface and returns new pitch and zoom to fix that.

With the new pitch and zoom, the camera will be at the same ground position but at higher altitude. It will still point to the same spot on the map.

Parameters ​

tr ​

ITransform

The transform to check.

Returns ​

ts
{
  pitch?: number;
  zoom?: number;
}
pitch? ​
ts
optional pitch?: number;
zoom? ​
ts
optional zoom?: number;

Inherited from ​

ts
MaplibreMap._elevateCameraIfInsideTerrain

_finalizeElevation() ​

ts
_finalizeElevation(): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:9113

Returns ​

void

Inherited from ​

ts
MaplibreMap._finalizeElevation

_fireMoveEvents() ​

ts
_fireMoveEvents(eventData?): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:9147

Parameters ​

eventData? ​

any

Returns ​

void

Inherited from ​

ts
MaplibreMap._fireMoveEvents

_fitInternal() ​

ts
_fitInternal(
   calculatedOptions?, 
   options?, 
   eventData?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:9016

Parameters ​

calculatedOptions? ​

CenterZoomBearing

options? ​

FitBoundsOptions

eventData? ​

any

Returns ​

this

Inherited from ​

ts
MaplibreMap._fitInternal

_getClampedPixelRatio() ​

ts
_getClampedPixelRatio(width, height): number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11641

Internal

Return the map's pixel ratio eventually scaled down to respect maxCanvasSize. Internally you should use this and not getPixelRatio().

Parameters ​

width ​

number

height ​

number

Returns ​

number

Inherited from ​

ts
MaplibreMap._getClampedPixelRatio

_getMapId() ​

ts
_getMapId(): number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11523

Internal

Returns a unique number for this map instance which is used for the MapLoadEvent to make sure we only fire one event per instantiated map object.

Returns ​

number

the uniq map ID

Inherited from ​

ts
MaplibreMap._getMapId

_getStyleAndImages() ​

ts
_getStyleAndImages(): LostContextStyle;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12319

Internal

Returns the map's style and cloned images to restore context.

Returns ​

LostContextStyle

An object containing the style and images.

Inherited from ​

ts
MaplibreMap._getStyleAndImages

_getTransformForUpdate() ​

ts
_getTransformForUpdate(): ITransform;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:9123

Internal

Called when the camera is about to be manipulated. If transformCameraUpdate is specified or terrain is enabled, a copy of the current transform is created to track the accumulated changes. This underlying transform represents the "desired state" proposed by input handlers / animations / UI controls. It may differ from the state used for rendering (this.transform).

Returns ​

ITransform

Transform to apply changes to

Inherited from ​

ts
MaplibreMap._getTransformForUpdate

_getUIString() ​

ts
_getUIString(key): string;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12297

Parameters ​

key ​

| "AttributionControl.ToggleAttribution" | "AttributionControl.MapFeedback" | "FullscreenControl.Enter" | "FullscreenControl.Exit" | "GeolocateControl.FindMyLocation" | "GeolocateControl.LocationNotAvailable" | "LogoControl.Title" | "Map.Title" | "Marker.Title" | "NavigationControl.ResetBearing" | "NavigationControl.ZoomIn" | "NavigationControl.ZoomOut" | "Popup.Close" | "ScaleControl.Feet" | "ScaleControl.Meters" | "ScaleControl.Kilometers" | "ScaleControl.Miles" | "ScaleControl.NauticalMiles" | "GlobeControl.Enable" | "GlobeControl.Disable" | "TerrainControl.Enable" | "TerrainControl.Disable" | "CooperativeGesturesHandler.WindowsHelpText" | "CooperativeGesturesHandler.MacHelpText" | "CooperativeGesturesHandler.MobileHelpText"

Returns ​

string

Inherited from ​

ts
MaplibreMap._getUIString

_lazyInitEmptyStyle() ​

ts
_lazyInitEmptyStyle(): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12299

Returns ​

void

Inherited from ​

ts
MaplibreMap._lazyInitEmptyStyle

_normalizeBearing() ​

ts
_normalizeBearing(bearing, currentBearing): number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:9198

Parameters ​

bearing ​

number

currentBearing ​

number

Returns ​

number

Inherited from ​

ts
MaplibreMap._normalizeBearing

_prepareEase() ​

ts
_prepareEase(
   eventData, 
   noMoveStart, 
   currently?): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:9104

Parameters ​

eventData ​

any

noMoveStart ​

boolean

currently? ​
moving? ​

boolean

pitching? ​

boolean

rolling? ​

boolean

rotating? ​

boolean

zooming? ​

boolean

Returns ​

void

Inherited from ​

ts
MaplibreMap._prepareEase

_prepareElevation() ​

ts
_prepareElevation(center): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:9111

Parameters ​

center ​

LngLat

Returns ​

void

Inherited from ​

ts
MaplibreMap._prepareElevation

_registerLayer() ​

ts
_registerLayer(layer): void;

Defined in: packages/core-libre/src/map/gmap.ts:341

内部:登记 GLayer

Parameters ​

layer ​

GLayer

Returns ​

void


_removeDelegatedListener() ​

ts
_removeDelegatedListener(
   type, 
   layerIds, 
   listener): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11922

Parameters ​

type ​

string

layerIds ​

string[]

listener ​

Listener

Returns ​

void

Inherited from ​

ts
MaplibreMap._removeDelegatedListener

_render() ​

ts
_render(paintStartTimeStamp): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13166

Internal

Call when a (re-)render of the map is required:

  • The style has changed (setPaintProperty(), etc.)
  • Source data has changed (e.g. tiles have finished loading)
  • The map has is moving (or just finished moving)
  • A transition is in progress

Parameters ​

paintStartTimeStamp ​

number

The time when the animation frame began executing.

Returns ​

this

Inherited from ​

ts
MaplibreMap._render

_requestRenderFrame() ​

ts
_requestRenderFrame(callback): number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13153

Internal

Request that the given callback be executed during the next render frame. Schedule a render frame if one is not already scheduled.

Parameters ​

callback ​

() => void

Returns ​

number

An id that can be used to cancel the callback

Inherited from ​

ts
MaplibreMap._requestRenderFrame

_resizeCanvas() ​

ts
_resizeCanvas(
   width, 
   height, 
   pixelRatio): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13122

Parameters ​

width ​

number

height ​

number

pixelRatio ​

number

Returns ​

void

Inherited from ​

ts
MaplibreMap._resizeCanvas

_resizeInternal() ​

ts
_resizeInternal(constrainTransform?): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11634

Internal

Resizes the map according to the dimensions of its container element.

It does not trigger any events, and does not check for context loss.

It is used internally and by Map.resize.

Parameters ​

constrainTransform? ​

boolean

whether to constrain the transform after resizing.

Returns ​

void

Inherited from ​

ts
MaplibreMap._resizeInternal

_resizeTransform() ​

ts
_resizeTransform(constrainTransform?): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11635

Parameters ​

constrainTransform? ​

boolean

Returns ​

void

Inherited from ​

ts
MaplibreMap._resizeTransform

_saveDelegatedListener() ​

ts
_saveDelegatedListener(type, delegatedListener): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11921

Parameters ​

type ​

string

delegatedListener ​

DelegatedListener

Returns ​

void

Inherited from ​

ts
MaplibreMap._saveDelegatedListener

_setupContainer() ​

ts
_setupContainer(): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13121

Returns ​

void

Inherited from ​

ts
MaplibreMap._setupContainer

_setupPainter() ​

ts
_setupPainter(): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13123

Returns ​

void

Inherited from ​

ts
MaplibreMap._setupPainter

_stop() ​

ts
_stop(allowGestures?, easeId?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:9191

Parameters ​

allowGestures? ​

boolean

easeId? ​

string

Returns ​

this

Inherited from ​

ts
MaplibreMap._stop

_unregisterLayer() ​

ts
_unregisterLayer(layer): void;

Defined in: packages/core-libre/src/map/gmap.ts:346

内部:注销 GLayer

Parameters ​

layer ​

GLayer

Returns ​

void


_update() ​

ts
_update(updateStyle?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13145

Internal

Update this map's style and sources, and re-render the map.

Parameters ​

updateStyle? ​

boolean

mark the map's style for reprocessing as well as its sources

Returns ​

this

Inherited from ​

ts
MaplibreMap._update

_updateDiff() ​

ts
_updateDiff(style, options?): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12301

Parameters ​

style ​

StyleSpecification

options? ​

StyleSwapOptions & StyleOptions

Returns ​

void

Inherited from ​

ts
MaplibreMap._updateDiff

_updateElevation() ​

ts
_updateElevation(k): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:9112

Parameters ​

k ​

number

Returns ​

void

Inherited from ​

ts
MaplibreMap._updateElevation

_updateStyle() ​

ts
_updateStyle(style, options?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12298

Parameters ​

style ​

string | StyleSpecification | null

options? ​

StyleSwapOptions & StyleOptions

Returns ​

this

Inherited from ​

ts
MaplibreMap._updateStyle

addControl() ​

ts
addControl(control, position?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11553

Adds an IControl to the map, calling control.onAdd(this).

An ErrorEvent will be fired if the control is invalid.

Parameters ​

control ​

IControl

The IControl to add.

position? ​

ControlPosition

position on the map to which the control will be added. Valid values are 'top-left', 'top-right', 'bottom-left', and 'bottom-right'. Defaults to 'top-right'.

Returns ​

this

Example ​

Add zoom and rotation controls to the map.

ts
map.addControl(new NavigationControl());

See ​

Display map navigation controls

Inherited from ​

ts
MaplibreMap.addControl

addImage() ​

ts
addImage(
   id, 
   image, 
   options?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12518

Add an image to the style. This image can be displayed on the map like any other icon in the style's sprite using the image's ID with icon-image, background-pattern, fill-pattern, or line-pattern.

A ErrorEvent event will be fired if the image parameter is invalid or there is not enough space in the sprite to add this image.

Parameters ​

id ​

string

The ID of the image.

image ​

| HTMLImageElement | ImageBitmap | ImageData | { data: | Uint8Array<ArrayBufferLike> | Uint8ClampedArray<ArrayBufferLike>; height: number; width: number; } | StyleImageInterface

The image as an HTMLImageElement, ImageData, ImageBitmap or object with width, height, and data properties with the same format as ImageData.

options? ​

Partial<StyleImageMetadata>

Options object.

Returns ​

this

Example ​

ts
// If the style's sprite does not already contain an image with ID 'cat',
// add the image 'cat-icon.png' to the style's sprite with the ID 'cat'.
const image = await map.loadImage('https://upload.wikimedia.org/wikipedia/commons/thumb/6/60/Cat_silhouette.svg/400px-Cat_silhouette.svg.png');
if (!map.hasImage('cat')) map.addImage('cat', image.data);

// Add a stretchable image that can be used with `icon-text-fit`
// In this example, the image is 600px wide by 400px high.
const image = await map.loadImage('https://upload.wikimedia.org/wikipedia/commons/8/89/Black_and_White_Boxed_%28bordered%29.png');
if (map.hasImage('border-image')) return;
map.addImage('border-image', image.data, {
    content: [16, 16, 300, 384], // place text over left half of image, avoiding the 16px border
    stretchX: [[16, 584]], // stretch everything horizontally except the 16px border
    stretchY: [[16, 384]], // stretch everything vertically except the 16px border
});

See ​

Inherited from ​

ts
MaplibreMap.addImage

addLayer() ​

Call Signature ​

ts
addLayer(layer): this;

Defined in: packages/core-libre/src/map/gmap.ts:309

加入图层:GLayer 走就绪门控安装;原生 style 图层透传给 maplibre

Parameters ​
layer ​

GLayer

Returns ​

this

Overrides ​
ts
MaplibreMap.addLayer

Call Signature ​

ts
addLayer(layer, beforeId?): this;

Defined in: packages/core-libre/src/map/gmap.ts:310

加入图层:GLayer 走就绪门控安装;原生 style 图层透传给 maplibre

Parameters ​
layer ​

AddLayerObject

beforeId? ​

string

Returns ​

this

Overrides ​
ts
MaplibreMap.addLayer

addSource() ​

ts
addSource(id, source): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12368

Adds a source to the map's style.

Events triggered:

Triggers the source.add event.

Parameters ​

id ​

string

The ID of the source to add. Must not conflict with existing sources.

source ​

SourceSpecification | CanvasSourceSpecification

The source object, conforming to the MapLibre Style Specification's source definition or CanvasSourceSpecification.

Returns ​

this

Examples ​

ts
map.addSource('my-data', {
  type: 'vector',
  url: 'https://demotiles.maplibre.org/tiles/tiles.json'
});
ts
map.addSource('my-data', {
  "type": "geojson",
  "data": {
    "type": "Feature",
    "geometry": {
      "type": "Point",
      "coordinates": [-77.0323, 38.9131]
    },
    "properties": {
      "title": "Mapbox DC",
      "marker-symbol": "monument"
    }
  }
});

See ​

GeoJSON source: Add live realtime data

Inherited from ​

ts
MaplibreMap.addSource

addSprite() ​

ts
addSprite(
   id, 
   url, 
   options?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12895

Adds a sprite to the map's style. Fires the style event.

Parameters ​

id ​

string

The ID of the sprite to add. Must not conflict with existing sprites.

url ​

string

The URL to load the sprite from

options? ​

StyleSetterOptions

Options object.

Returns ​

this

Example ​

ts
map.addSprite('sprite-two', 'http://example.com/sprite-two');

Inherited from ​

ts
MaplibreMap.addSprite

areTilesLoaded() ​

ts
areTilesLoaded(): boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12414

Returns a Boolean indicating whether all tiles in the viewport from all sources on the style are loaded.

Returns ​

boolean

A Boolean indicating whether all tiles are loaded.

Example ​

ts
let tilesLoaded = map.areTilesLoaded();

Inherited from ​

ts
MaplibreMap.areTilesLoaded

calculateCameraOptionsFromCameraLngLatAltRotation() ​

ts
calculateCameraOptionsFromCameraLngLatAltRotation(
   cameraLngLat, 
   cameraAlt, 
   bearing, 
   pitch, 
   roll?): CameraOptions;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:9084

Given a camera position and rotation, calculates zoom and center point and returns them as CameraOptions.

Parameters ​

cameraLngLat ​

LngLatLike

The lng, lat of the camera to look from

cameraAlt ​

number

The altitude of the camera to look from, in meters above sea level

bearing ​

number

Bearing of the camera, in degrees

pitch ​

number

Pitch of the camera, in degrees

roll? ​

number

Roll of the camera, in degrees

Returns ​

CameraOptions

the calculated camera options

Example ​

ts
// Calculate options to look from camera position(1°, 0°, 1000m) with bearing = 90°, pitch = 30°, and roll = 45°
const cameraLngLat = new LngLat(1, 0);
const cameraAltitude = 1000;
const bearing = 90;
const pitch = 30;
const roll = 45;
const cameraOptions = map.calculateCameraOptionsFromCameraLngLatAltRotation(cameraLngLat, cameraAltitude, bearing, pitch, roll);
// Apply calculated options
map.jumpTo(cameraOptions);

Inherited from ​

ts
MaplibreMap.calculateCameraOptionsFromCameraLngLatAltRotation

calculateCameraOptionsFromTo() ​

ts
calculateCameraOptionsFromTo(
   from, 
   altitudeFrom, 
   to, 
   altitudeTo?): CameraOptions;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11600

Given a camera 'from' position and a position to look at (to), calculates zoom and camera rotation and returns them as CameraOptions.

Parameters ​

from ​

LngLat

The camera to look from

altitudeFrom ​

number

The altitude of the camera to look from

to ​

LngLat

The center to look at

altitudeTo? ​

number

Optional altitude of the center to look at. If none given the ground height will be used.

Returns ​

CameraOptions

the calculated camera options

Example ​

ts
// Calculate options to look from (1°, 0°, 1000m) to (1°, 1°, 0m)
const cameraLngLat = new LngLat(1, 0);
const cameraAltitude = 1000;
const targetLngLat = new LngLat(1, 1);
const targetAltitude = 0;
const cameraOptions = map.calculateCameraOptionsFromTo(cameraLngLat, cameraAltitude, targetLngLat, targetAltitude);
// Apply calculated options
map.jumpTo(cameraOptions);

Inherited from ​

ts
MaplibreMap.calculateCameraOptionsFromTo

cameraForBounds() ​

ts
cameraForBounds(bounds, options?): CenterZoomBearing | undefined;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8949

Parameters ​

bounds ​

LngLatBoundsLike

Calculate the center for these bounds in the viewport and use the highest zoom level up to and including Map.getMaxZoom that fits in the viewport. LngLatBounds represent a box that is always axis-aligned with bearing 0. Bounds will be taken in [sw, ne] order. Southwest point will always be to the left of the northeast point.

options? ​

CameraForBoundsOptions

Options object

Returns ​

CenterZoomBearing | undefined

If map is able to fit to provided bounds, returns center, zoom, and bearing. If map is unable to fit, method will warn and return undefined.

Example ​

ts
let bbox = [[-79, 43], [-73, 45]];
let newCameraTransform = map.cameraForBounds(bbox, {
  padding: {top: 10, bottom:25, left: 15, right: 5}
});

Inherited from ​

ts
MaplibreMap.cameraForBounds

coveringTiles() ​

ts
coveringTiles(options): OverscaledTileID[];

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11599

Returns an array of OverscaledTileID objects that cover the current viewport for a given tile size. This method is useful for determining which tiles are visible in the current viewport.

Parameters ​

options ​

CoveringTilesOptions

Options for calculating the covering tiles.

Returns ​

OverscaledTileID[]

An array of OverscaledTileID objects.

Example ​

ts
// Get the tiles to cover the view for a 512x512px tile source
const tiles = map.coveringTiles({tileSize: 512});

Inherited from ​

ts
MaplibreMap.coveringTiles

destroy() ​

ts
destroy(): void;

Defined in: packages/core-libre/src/map/gmap.ts:410

销毁地图(释放 WebGL 上下文与 DOM,等价于原生 remove)

Returns ​

void


easeTo() ​

ts
easeTo(options, eventData?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:9103

Changes any combination of center, zoom, bearing, pitch, roll, and padding with an animated transition between old and new values. The map will retain its current values for any details not specified in options.

!!! note "Reduced Motion" The transition will happen instantly if the user has enabled the reduced motion accessibility feature enabled in their operating system, unless options includes essential: true.

Triggers the following events: movestart, move, moveend, zoomstart, zoom, zoomend, pitchstart, pitch, pitchend, rollstart, roll, rollend, and rotate.

Parameters ​

options ​

EaseToOptions

Options describing the destination and animation of the transition. Accepts CameraOptions and AnimationOptions.

eventData? ​

any

Additional properties to be added to event objects of events triggered by this method.

Returns ​

this

See ​

Navigate the map with game-like controls

Inherited from ​

ts
MaplibreMap.easeTo

ensureImage() ​

ts
ensureImage(url): Promise<void>;

Defined in: packages/core-libre/src/map/gmap.ts:383

确保图标图像已加载并注册到当前 style(幂等)

Parameters ​

url ​

string

Returns ​

Promise<void>


fire() ​

ts
fire(event, properties?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:855

Parameters ​

event ​

string | Event$1

properties? ​

any

Returns ​

this

Inherited from ​

ts
MaplibreMap.fire

fitBounds() ​

ts
fitBounds(...args): this;

Defined in: packages/core-libre/src/map/gmap.ts:227

Pans and zooms the map to contain its visible area within the specified geographical bounds. This function will also reset the map's bearing to 0 if bearing is nonzero.

Triggers the following events: movestart and moveend.

Parameters ​

args ​

...[LngLatBoundsLike, FitBoundsOptions, any]

Returns ​

this

Example ​

ts
let bbox = [[-79, 43], [-73, 45]];
map.fitBounds(bbox, {
  padding: {top: 10, bottom:25, left: 15, right: 5}
});

See ​

Fit a map to a bounding box

Overrides ​

ts
MaplibreMap.fitBounds

fitScreenCoordinates() ​

ts
fitScreenCoordinates(
   p0, 
   p1, 
   bearing, 
   options?, 
   eventData?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:9015

Pans, rotates and zooms the map to to fit the box made by points p0 and p1 once the map is rotated to the specified bearing. To zoom without rotating, pass in the current map bearing.

Triggers the following events: movestart, move, moveend, zoomstart, zoom, zoomend and rotate.

Parameters ​

p0 ​

PointLike

First point on screen, in pixel coordinates

p1 ​

PointLike

Second point on screen, in pixel coordinates

bearing ​

number

Desired map bearing at end of animation, in degrees

options? ​

FitBoundsOptions

Options object

eventData? ​

any

Additional properties to be added to event objects of events triggered by this method.

Returns ​

this

Example ​

ts
let p0 = [220, 400];
let p1 = [500, 900];
map.fitScreenCoordinates(p0, p1, map.getBearing(), {
  padding: {top: 10, bottom:25, left: 15, right: 5}
});

See ​

Used by BoxZoomHandler

Inherited from ​

ts
MaplibreMap.fitScreenCoordinates

flyTo() ​

ts
flyTo(...args): this;

Defined in: packages/core-libre/src/map/gmap.ts:212

Changes any combination of center, zoom, bearing, pitch, and roll, animating the transition along a curve that evokes flight. The animation seamlessly incorporates zooming and panning to help the user maintain her bearings even after traversing a great distance.

!!! note "Reduced Motion" The animation will be skipped, and this will behave equivalently to jumpTo if the user has the reduced motion accessibility feature enabled in their operating system, unless 'options' includes essential: true.

Triggers the following events: movestart, move, moveend, zoomstart, zoom, zoomend, pitchstart, pitch, pitchend, rollstart, roll, rollend, and rotate.

Parameters ​

args ​

...[FlyToOptions, any]

Returns ​

this

Example ​

ts
// fly with default options to null island
map.flyTo({center: [0, 0], zoom: 9});
// using flyTo options
map.flyTo({
  center: [0, 0],
  zoom: 9,
  speed: 0.2,
  curve: 1,
  easing(t) {
    return t;
  }
});

See ​

Overrides ​

ts
MaplibreMap.flyTo

fromWGS84() ​

ts
fromWGS84(ll): [number, number];

Defined in: packages/core-libre/src/map/gmap.ts:129

WGS-84 → 当前基准面(把 WGS-84 坐标转成地图空间坐标)

Parameters ​

ll ​

LngLatLike

Returns ​

[number, number]


getAnisotropicFilterPitch() ​

ts
getAnisotropicFilterPitch(): number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11801

Returns the map's anisotropic filter pitch. If the map is pitched beyond this threshold, anisotropic filtering will be applied to all raster layers.

Returns ​

number

The anisotropicFilterPitch

Example ​

ts
let anisotropicFilterPitch = map.getAnisotropicFilterPitch();

Inherited from ​

ts
MaplibreMap.getAnisotropicFilterPitch

getBearing() ​

ts
getBearing(): number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8812

Returns the map's current bearing. The bearing is the compass direction that is "up"; for example, a bearing of 90° orients the map so that east is up.

Returns ​

number

The map's current bearing.

See ​

Navigate the map with game-like controls

Inherited from ​

ts
MaplibreMap.getBearing

getBounds() ​

ts
getBounds(): LngLatBounds;

Defined in: packages/core-libre/src/map/gmap.ts:251

视野范围(WGS-84;按当前 datum 反算四角)

Returns ​

LngLatBounds

Overrides ​

ts
MaplibreMap.getBounds

getCameraTargetElevation() ​

ts
getCameraTargetElevation(): number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13255

Returns the elevation for the point where the camera is looking. This value corresponds to: "meters above sea level" * "exaggeration"

Returns ​

number

The elevation.

Inherited from ​

ts
MaplibreMap.getCameraTargetElevation

getCanvas() ​

ts
getCanvas(): HTMLCanvasElement;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13107

Returns the map's <canvas> element.

Returns ​

HTMLCanvasElement

The map's <canvas> element.

See ​

Inherited from ​

ts
MaplibreMap.getCanvas

getCanvasContainer() ​

ts
getCanvasContainer(): HTMLElement;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13098

Returns the HTML element containing the map's <canvas> element.

If you want to add non-GL overlays to the map, you should append them to this element.

This is the element to which event bindings for map interactivity (such as panning and zooming) are attached. It will receive bubbled events from child elements such as the <canvas>, but not from map controls.

Returns ​

HTMLElement

The container of the map's <canvas>.

See ​

Create a draggable point

Inherited from ​

ts
MaplibreMap.getCanvasContainer

getCenter() ​

ts
getCenter(): LngLat;

Defined in: packages/core-libre/src/map/gmap.ts:245

地图中心(WGS-84 经纬度)

Returns ​

LngLat

Overrides ​

ts
MaplibreMap.getCenter

getCenterClampedToGround() ​

ts
getCenterClampedToGround(): boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8669

Returns the value of centerClampedToGround.

If true, the elevation of the center point will automatically be set to the terrain elevation (or zero if terrain is not enabled). If false, the elevation of the center point will default to sea level and will not automatically update. Defaults to true. Needs to be set to false to keep the camera above ground when pitch > 90 degrees.

Returns ​

boolean

Inherited from ​

ts
MaplibreMap.getCenterClampedToGround

getCenterElevation() ​

ts
getCenterElevation(): number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8651

Returns the elevation of the map's center point.

Returns ​

number

The elevation of the map's center point, in meters above sea level.

Inherited from ​

ts
MaplibreMap.getCenterElevation

getContainer() ​

ts
getContainer(): HTMLElement;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13085

Returns the map's containing HTML element.

Returns ​

HTMLElement

The map's container.

Inherited from ​

ts
MaplibreMap.getContainer

getDatum() ​

ts
getDatum(): Datum;

Defined in: packages/core-libre/src/map/gmap.ts:124

当前底图基准面('WGS84' | 'GCJ02' | 'BD09')

Returns ​

Datum


getFeatureState() ​

ts
getFeatureState(feature): any;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13079

Gets the state of a feature. A feature's state is a set of user-defined key-value pairs that are assigned to a feature at runtime. Features are identified by their feature.id attribute, which can be any number or string.

!!! note To access the values in a feature's state object for the purposes of styling the feature, use the feature-state expression.

Parameters ​

feature ​

FeatureIdentifier

Feature identifier. Feature objects returned from Map.queryRenderedFeatures or event handlers can be used as feature identifiers.

Returns ​

any

The state of the feature: a set of key-value pairs that was assigned to the feature at runtime.

Example ​

When the mouse moves over the my-layer layer, get the feature state for the feature under the mouse

ts
map.on('mousemove', 'my-layer', (e) => {
  if (e.features.length > 0) {
    map.getFeatureState({
      source: 'my-source',
      sourceLayer: 'my-source-layer',
      id: e.features[0].id
    });
  }
});

Inherited from ​

ts
MaplibreMap.getFeatureState

getFilter() ​

ts
getFilter(layerId): void | FilterSpecification;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12819

Returns the filter applied to the specified style layer.

Parameters ​

layerId ​

string

The ID of the style layer whose filter to get.

Returns ​

void | FilterSpecification

The layer's filter.

Inherited from ​

ts
MaplibreMap.getFilter

getGlobalState() ​

ts
getGlobalState(): Record<string, any>;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11537

Returns the global map state

Returns ​

Record<string, any>

The map state object.

Inherited from ​

ts
MaplibreMap.getGlobalState

getGlyphs() ​

ts
getGlyphs(): string | null;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12883

Returns the value of the style's glyphs URL

Returns ​

string | null

glyphs Style's glyphs url, or null if glyphs are unset.

Inherited from ​

ts
MaplibreMap.getGlyphs

getImage() ​

ts
getImage(id): StyleImage;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12561

Returns an image, specified by ID, currently available in the map. This includes both images from the style's original sprite and any images that have been added at runtime using Map.addImage.

Parameters ​

id ​

string

The ID of the image.

Returns ​

StyleImage

An image in the map with the specified ID.

Example ​

ts
let coffeeShopIcon = map.getImage("coffee_cup");

Inherited from ​

ts
MaplibreMap.getImage

getLayer() ​

ts
getLayer(id): StyleLayer | undefined;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12745

Returns the layer with the specified ID in the map's style.

Parameters ​

id ​

string

The ID of the layer to get.

Returns ​

StyleLayer | undefined

The layer with the specified ID, or undefined if the ID corresponds to no existing layers.

Example ​

ts
let stateDataLayer = map.getLayer('state-data');

See ​

Inherited from ​

ts
MaplibreMap.getLayer

getLayerById() ​

ts
getLayerById(id): GLayer | undefined;

Defined in: packages/core-libre/src/map/gmap.ts:333

按 id 获取本库管理的 GLayer

Parameters ​

id ​

string

Returns ​

GLayer | undefined


getLayersOrder() ​

ts
getLayersOrder(): string[];

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12756

Return the ids of all layers currently in the style, including custom layers, in order.

Returns ​

string[]

ids of layers, in order

Example ​

ts
const orderedLayerIds = map.getLayersOrder();

Inherited from ​

ts
MaplibreMap.getLayersOrder

getLayoutProperty() ​

ts
getLayoutProperty(layerId, name): any;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12865

Returns the value of a layout property in the specified style layer.

Parameters ​

layerId ​

string

The ID of the layer to get the layout property from.

name ​

string

The name of the layout property to get.

Returns ​

any

The value of the specified layout property.

Inherited from ​

ts
MaplibreMap.getLayoutProperty

getLight() ​

ts
getLight(): LightSpecification;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12944

Returns the value of the light object.

Returns ​

LightSpecification

light Light properties of the style.

Inherited from ​

ts
MaplibreMap.getLight

getMaxBounds() ​

ts
getMaxBounds(): LngLatBounds | null;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11675

Returns the maximum geographical bounds the map is constrained to, or null if none set.

Returns ​

LngLatBounds | null

The map object.

Example ​

ts
let maxBounds = map.getMaxBounds();

Inherited from ​

ts
MaplibreMap.getMaxBounds

getMaxPitch() ​

ts
getMaxPitch(): number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11790

Returns the map's maximum allowable pitch.

Returns ​

number

The maxPitch

Inherited from ​

ts
MaplibreMap.getMaxPitch

getMaxZoom() ​

ts
getMaxZoom(): number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11754

Returns the map's maximum allowable zoom level.

Returns ​

number

The maxZoom

Example ​

ts
let maxZoom = map.getMaxZoom();

Inherited from ​

ts
MaplibreMap.getMaxZoom

getMinPitch() ​

ts
getMinPitch(): number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11772

Returns the map's minimum allowable pitch.

Returns ​

number

The minPitch

Inherited from ​

ts
MaplibreMap.getMinPitch

getMinZoom() ​

ts
getMinZoom(): number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11728

Returns the map's minimum allowable zoom level.

Returns ​

number

minZoom

Example ​

ts
let minZoom = map.getMinZoom();

Inherited from ​

ts
MaplibreMap.getMinZoom

getPadding() ​

ts
getPadding(): PaddingOptions;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8847

Returns the current padding applied around the map viewport.

Returns ​

PaddingOptions

The current padding around the map viewport.

Inherited from ​

ts
MaplibreMap.getPadding

getPaintProperty() ​

ts
getPaintProperty(layerId, name): unknown;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12844

Returns the value of a paint property in the specified style layer.

Parameters ​

layerId ​

string

The ID of the layer to get the paint property from.

name ​

string

The name of a paint property to get.

Returns ​

unknown

The value of the specified paint property.

Inherited from ​

ts
MaplibreMap.getPaintProperty

getPitch() ​

ts
getPitch(): number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8908

Returns the map's current pitch (tilt).

Returns ​

number

The map's current pitch, measured in degrees away from the plane of the screen.

Inherited from ​

ts
MaplibreMap.getPitch

getPixelRatio() ​

ts
getPixelRatio(): number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11647

Returns the map's pixel ratio. Note that the pixel ratio actually applied may be lower to respect maxCanvasSize.

Returns ​

number

The pixel ratio.

Inherited from ​

ts
MaplibreMap.getPixelRatio

getProjection() ​

ts
getProjection(): ProjectionSpecification;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13264

Gets the ProjectionSpecification.

Returns ​

ProjectionSpecification

the projection specification.

Example ​

ts
let projection = map.getProjection();

Inherited from ​

ts
MaplibreMap.getProjection

getRenderWorldCopies() ​

ts
getRenderWorldCopies(): boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11831

Returns the state of renderWorldCopies. If true, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to false:

  • When the map is zoomed out far enough that a single representation of the world does not fill the map's entire container, there will be blank space beyond 180 and -180 degrees longitude.
  • Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the map and the other on the left edge of the map) at every zoom level.

Returns ​

boolean

The renderWorldCopies

Example ​

ts
let worldCopiesRendered = map.getRenderWorldCopies();

See ​

Render world copies

Inherited from ​

ts
MaplibreMap.getRenderWorldCopies

getRoll() ​

ts
getRoll(): number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8923

Returns the map's current roll angle.

Returns ​

number

The map's current roll, measured in degrees about the camera boresight.

Inherited from ​

ts
MaplibreMap.getRoll

getSky() ​

ts
getSky(): SkySpecification;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12966

Returns the value of the style's sky.

Returns ​

SkySpecification

the sky properties of the style.

Example ​

ts
map.getSky();

Inherited from ​

ts
MaplibreMap.getSky

getSource() ​

ts
getSource<TSource>(id): TSource | undefined;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12447

Returns the source with the specified ID in the map's style.

This method is often used to update a source using the instance members for the relevant source type as defined in classes that derive from Source. For example, setting the data for a GeoJSON source or updating the url and coordinates of an image source.

Type Parameters ​

TSource ​

TSource extends Source

Parameters ​

id ​

string

The ID of the source to get.

Returns ​

TSource | undefined

The style source with the specified ID or undefined if the ID corresponds to no existing sources. The shape of the object varies by source type. A list of options for each source type is available on the MapLibre Style Specification's Sources page.

Example ​

ts
let sourceObject = map.getSource('points');

See ​

Inherited from ​

ts
MaplibreMap.getSource

getSprite() ​

ts
getSprite(): {
  id: string;
  url: string;
}[];

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12912

Returns the as-is value of the style's sprite.

Returns ​

{ id: string; url: string; }[]

style's sprite list of id-url pairs

Inherited from ​

ts
MaplibreMap.getSprite

getStyle() ​

ts
getStyle(): StyleSpecification;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12313

Returns the map's MapLibre style object, a JSON object which can be used to recreate the map's style.

Returns ​

StyleSpecification

The map's style JSON object.

Example ​

ts
let styleJson = map.getStyle();

Inherited from ​

ts
MaplibreMap.getStyle

getTerrain() ​

ts
getTerrain(): TerrainSpecification | null;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12403

Get the terrain-options if terrain is loaded

Returns ​

TerrainSpecification | null

the TerrainSpecification passed to setTerrain

Example ​

ts
map.getTerrain(); // { source: 'terrain' };

Inherited from ​

ts
MaplibreMap.getTerrain

getVerticalFieldOfView() ​

ts
getVerticalFieldOfView(): number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8789

Returns the map's current vertical field of view, in degrees.

Returns ​

number

The map's current vertical field of view.

Default Value ​

ts
36.87

Example ​

ts
const verticalFieldOfView = map.getVerticalFieldOfView();

Inherited from ​

ts
MaplibreMap.getVerticalFieldOfView

getZoom() ​

ts
getZoom(): number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8716

Returns the map's current zoom level.

Returns ​

number

The map's current zoom level.

Example ​

ts
map.getZoom();

Inherited from ​

ts
MaplibreMap.getZoom

getZoomSnap() ​

ts
getZoomSnap(): number;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8824

Returns the map's current zoom snap level.

Returns ​

number

The map's current zoom snap level.

Inherited from ​

ts
MaplibreMap.getZoomSnap

hasControl() ​

ts
hasControl(control): boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11586

Checks if a control exists on the map.

Parameters ​

control ​

IControl

The IControl to check.

Returns ​

boolean

true if map contains control.

Example ​

ts
// Define a new navigation control.
let navigation = new NavigationControl();
// Add zoom and rotation controls to the map.
map.addControl(navigation);
// Check that the navigation control exists on the map.
map.hasControl(navigation);

Inherited from ​

ts
MaplibreMap.hasControl

hasImage() ​

ts
hasImage(id): boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12578

Check whether or not an image with a specific ID exists in the style. This checks both images in the style's original sprite and any images that have been added at runtime using Map.addImage.

An ErrorEvent will be fired if the image ID is missing.

Parameters ​

id ​

string

The ID of the image.

Returns ​

boolean

A Boolean indicating whether the image exists.

Example ​

Check if an image with the ID 'cat' exists in the style's sprite.

ts
let catIconExists = map.hasImage('cat');

Inherited from ​

ts
MaplibreMap.hasImage

isEasing() ​

ts
isEasing(): boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:9186

Returns ​

boolean

Inherited from ​

ts
MaplibreMap.isEasing

isMoving() ​

ts
isMoving(): boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11901

Returns true if the map is panning, zooming, rotating, or pitching due to a camera animation or user gesture.

Returns ​

boolean

true if the map is moving.

Example ​

ts
let isMoving = map.isMoving();

Inherited from ​

ts
MaplibreMap.isMoving

isReady() ​

ts
isReady(): boolean;

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

style 是否已就绪(可安全 addSource / addLayer)。

以本库自管的 styleReady('style.load' 时置位、setBase 时复位)为准, 不用 maplibre 的 isStyleLoaded()——后者会在我们于 style.load 回调里 同步加图层时短暂翻回 false(有待处理的样式操作),造成误判。

Returns ​

boolean


isRotating() ​

ts
isRotating(): boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11919

Returns true if the map is rotating due to a camera animation or user gesture.

Returns ​

boolean

true if the map is rotating.

Example ​

ts
map.isRotating();

Inherited from ​

ts
MaplibreMap.isRotating

isSourceLoaded() ​

ts
isSourceLoaded(id): boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12382

Returns a Boolean indicating whether the source is loaded. Returns true if the source with the given ID in the map's style has no outstanding network requests, otherwise false.

A ErrorEvent event will be fired if there is no source with the specified ID.

Parameters ​

id ​

string

The ID of the source to be checked.

Returns ​

boolean

A Boolean indicating whether the source is loaded.

Example ​

ts
let sourceLoaded = map.isSourceLoaded('bathymetry-data');

Inherited from ​

ts
MaplibreMap.isSourceLoaded

isStyleLoaded() ​

ts
isStyleLoaded(): boolean | void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12330

Returns a Boolean indicating whether the map's style is fully loaded.

Returns ​

boolean | void

A Boolean indicating whether the style is fully loaded.

Example ​

ts
let styleLoadStatus = map.isStyleLoaded();

Inherited from ​

ts
MaplibreMap.isStyleLoaded

isZooming() ​

ts
isZooming(): boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11910

Returns true if the map is zooming due to a camera animation or user gesture.

Returns ​

boolean

true if the map is zooming.

Example ​

ts
let isZooming = map.isZooming();

Inherited from ​

ts
MaplibreMap.isZooming

jumpTo() ​

ts
jumpTo(options, eventData?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:9042

Changes any combination of center, zoom, bearing, pitch, and roll, without an animated transition. The map will retain its current values for any details not specified in options.

Triggers the following events: movestart, move, moveend, zoomstart, zoom, zoomend, pitchstart, pitch, pitchend, rollstart, roll, rollend and rotate.

Parameters ​

options ​

JumpToOptions

Options object

eventData? ​

any

Additional properties to be added to event objects of events triggered by this method.

Returns ​

this

Example ​

ts
// jump to coordinates at current zoom
map.jumpTo({center: [0, 0]});
// jump with zoom, pitch, and bearing options
map.jumpTo({
  center: [0, 0],
  zoom: 8,
  pitch: 45,
  bearing: 90
});

See ​

Inherited from ​

ts
MaplibreMap.jumpTo

listens() ​

ts
listens(type): boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:862

Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type.

Parameters ​

type ​

string

The event type

Returns ​

boolean

true if there is at least one registered listener for specified event type, false otherwise

Inherited from ​

ts
MaplibreMap.listens

listImages() ​

ts
listImages(): string[];

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12623

Returns an Array of strings containing the IDs of all images currently available in the map. This includes both images from the style's original sprite and any images that have been added at runtime using Map.addImage.

Returns ​

string[]

An Array of strings containing the names of all sprites/images currently available in the map.

Example ​

ts
let allImages = map.listImages();

Inherited from ​

ts
MaplibreMap.listImages

loaded() ​

ts
loaded(): boolean;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13137

Returns a Boolean indicating whether the map is fully loaded.

Returns false if the style is not yet fully loaded, or if there has been a change to the sources or style that has not yet fully loaded.

Returns ​

boolean

A Boolean indicating whether the map is fully loaded.

Inherited from ​

ts
MaplibreMap.loaded

loadImage() ​

ts
loadImage(url): Promise<GetResourceResponse<HTMLImageElement | ImageBitmap>>;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12610

Load an image from an external URL to be used with Map.addImage. External domains must support CORS.

Parameters ​

url ​

string

The URL of the image file. Image file must be in png, webp, or jpg format.

Returns ​

Promise<GetResourceResponse<HTMLImageElement | ImageBitmap>>

a promise that is resolved when the image is loaded

Example ​

Load an image from an external URL.

ts
const response = await map.loadImage('https://picsum.photos/50/50');
// Add the loaded image to the style's sprite with the ID 'photo'.
map.addImage('photo', response.data);

See ​

Add an icon to the map

Inherited from ​

ts
MaplibreMap.loadImage

migrateProjection() ​

ts
migrateProjection(newTransform, newCameraHelper): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13124

Internal

Creates a new specialized transform instance from a projection instance and migrates to this new transform, carrying over all the properties of the old transform (center, pitch, etc.). When the style's projection is changed (or first set), this function should be called.

Parameters ​

newTransform ​

ITransform

newCameraHelper ​

ICameraHelper

Returns ​

void

Inherited from ​

ts
MaplibreMap.migrateProjection

moveLayer() ​

ts
moveLayer(id, beforeId?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12716

Moves a layer to a different z-position.

Parameters ​

id ​

string

The ID of the layer to move.

beforeId? ​

string

The ID of an existing layer to insert the new layer before. When viewing the map, the id layer will appear beneath the beforeId layer. If beforeId is omitted, the layer will be appended to the end of the layers array and appear above all other layers on the map.

Returns ​

this

Example ​

Move a layer with ID 'polygon' before the layer with ID 'country-label'. The polygon layer will appear beneath the country-label layer on the map.

ts
map.moveLayer('polygon', 'country-label');

Inherited from ​

ts
MaplibreMap.moveLayer

panBy() ​

ts
panBy(...args): this;

Defined in: packages/core-libre/src/map/gmap.ts:201

Pans the map by the specified offset.

Triggers the following events: movestart and moveend.

Parameters ​

args ​

...[PointLike, EaseToOptions, any]

Returns ​

this

See ​

Navigate the map with game-like controls

Overrides ​

ts
MaplibreMap.panBy

panTo() ​

ts
panTo(...args): this;

Defined in: packages/core-libre/src/map/gmap.ts:186

Pans the map to the specified location with an animated transition.

Triggers the following events: movestart and moveend.

Parameters ​

args ​

...[LngLatLike, EaseToOptions, any]

Returns ​

this

Example ​

ts
map.panTo([-74, 38]);
// Specify that the panTo animation should last 5000 milliseconds.
map.panTo([-74, 38], {duration: 5000});

See ​

Update a feature in realtime

Overrides ​

ts
MaplibreMap.panTo

project() ​

ts
project(lnglat): Point;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11877

Returns a Point representing pixel coordinates, relative to the map's container, that correspond to the specified geographical location.

Parameters ​

lnglat ​

LngLatLike

The geographical location to project.

Returns ​

Point

The Point corresponding to lnglat, relative to the map's container.

Example ​

ts
let coordinate = [-122.420679, 37.772537];
let point = map.project(coordinate);

Inherited from ​

ts
MaplibreMap.project

queryRenderedFeatures() ​

ts
queryRenderedFeatures(...args): MapGeoJSONFeature[];

Defined in: packages/core-libre/src/map/gmap.ts:270

渲染要素查询:返回几何反算为 WGS-84(与本库 WGS-84 契约一致)。

maplibre 原生返回的是地图空间(datum)几何;国内底图下逐要素 inverse 到 WGS-84,使原本的"边界泄漏"路径也保持 WGS-84。WGS84 底图为恒等(零开销)。 就地改写 geometry 以保留 MapGeoJSONFeature 实例与其余字段/方法。

Parameters ​

args ​

...[PointLike | [PointLike, PointLike] | QueryRenderedFeaturesOptions, QueryRenderedFeaturesOptions]

Returns ​

MapGeoJSONFeature[]

Overrides ​

ts
MaplibreMap.queryRenderedFeatures

querySourceFeatures() ​

ts
querySourceFeatures(sourceId, parameters?): GeoJSONFeature[];

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12236

Returns an array of MapGeoJSONFeature objects representing features within the specified vector tile or GeoJSON source that satisfy the query parameters.

Parameters ​

sourceId ​

string

The ID of the vector tile or GeoJSON source to query.

parameters? ​

QuerySourceFeatureOptions | null

The options object.

Returns ​

GeoJSONFeature[]

An array of MapGeoJSONFeature objects.

In contrast to Map.queryRenderedFeatures, this function returns all features matching the query parameters, whether or not they are rendered by the current style (i.e. visible). The domain of the query includes all currently-loaded vector tiles and GeoJSON source tiles: this function does not check tiles outside the currently visible viewport.

Because features come from tiled vector data or GeoJSON data that is converted to tiles internally, feature geometries may be split or duplicated across tile boundaries and, as a result, features may appear multiple times in query results. For example, suppose there is a highway running through the bounding rectangle of a query. The results of the query will be those parts of the highway that lie within the map tiles covering the bounding rectangle, even if the highway extends into other tiles, and the portion of the highway within each map tile will be returned as a separate feature. Similarly, a point feature near a tile boundary may appear in multiple tiles due to tile buffering.

Example ​

Find all features in one source layer in a vector source

ts
let features = map.querySourceFeatures('your-source-id', {
  sourceLayer: 'your-source-layer'
});

Inherited from ​

ts
MaplibreMap.querySourceFeatures

queryTerrainElevation() ​

ts
queryTerrainElevation(lngLatLike): number | null;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:9207

Gets the elevation at a given location, in meters above sea level. Returns null if terrain is not enabled. If terrain is enabled with some exaggeration value, the value returned here will be reflective of (multiplied by) that exaggeration value. This method should be used for proper positioning of custom 3d objects, as explained here

Parameters ​

lngLatLike ​

LngLatLike

[x,y] or LngLat coordinates of the location

Returns ​

number | null

elevation in meters

Inherited from ​

ts
MaplibreMap.queryTerrainElevation

redraw() ​

ts
redraw(): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13174

Force a synchronous redraw of the map.

Returns ​

this

Example ​

ts
map.redraw();

Inherited from ​

ts
MaplibreMap.redraw

refreshTiles() ​

ts
refreshTiles(sourceId, tileIds?): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12479

Triggers a reload of the selected tiles

Parameters ​

sourceId ​

string

The ID of the source

tileIds? ​

{ x: number; y: number; z: number; }[]

An array of tile IDs to be reloaded. If not defined, all tiles will be reloaded.

Returns ​

void

Example ​

ts
map.refreshTiles('satellite', [{x:1024, y: 1023, z: 11}, {x:1023, y: 1023, z: 11}]);

Inherited from ​

ts
MaplibreMap.refreshTiles

remove() ​

ts
remove(): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13184

Clean up and release all internal resources associated with this map.

This includes DOM elements, event bindings, web workers, and WebGL resources.

Use this method when you are done using the map and wish to ensure that it no longer consumes browser resources. Afterwards, you must not call any other methods on the map.

Returns ​

void

Inherited from ​

ts
MaplibreMap.remove

removeControl() ​

ts
removeControl(control): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11570

Removes the control from the map.

An ErrorEvent will be fired if the control is invalid.

Parameters ​

control ​

IControl

The IControl to remove.

Returns ​

this

Example ​

ts
// Define a new navigation control.
let navigation = new NavigationControl();
// Add zoom and rotation controls to the map.
map.addControl(navigation);
// Remove zoom and rotation controls from the map.
map.removeControl(navigation);

Inherited from ​

ts
MaplibreMap.removeControl

removeFeatureState() ​

ts
removeFeatureState(target, key?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13051

Removes the state of a feature, setting it back to the default behavior. If only a target.source is specified, it will remove the state for all features from that source. If target.id is also specified, it will remove all keys for that feature's state. If key is also specified, it removes only that key from that feature's state. Features are identified by their feature.id attribute, which can be any number or string.

Parameters ​

target ​

FeatureIdentifier

Identifier of where to remove state. It can be a source, a feature, or a specific key of feature. Feature objects returned from Map.queryRenderedFeatures or event handlers can be used as feature identifiers.

key? ​

string

(optional) The key in the feature state to reset.

Returns ​

this

Examples ​

Reset the entire state object for all features in the my-source source

ts
map.removeFeatureState({
  source: 'my-source'
});

When the mouse leaves the my-layer layer, reset the entire state object for the feature under the mouse

ts
map.on('mouseleave', 'my-layer', (e) => {
  map.removeFeatureState({
    source: 'my-source',
    sourceLayer: 'my-source-layer',
    id: e.features[0].id
  });
});

When the mouse leaves the my-layer layer, reset only the hover key-value pair in the state for the feature under the mouse

ts
map.on('mouseleave', 'my-layer', (e) => {
  map.removeFeatureState({
    source: 'my-source',
    sourceLayer: 'my-source-layer',
    id: e.features[0].id
  }, 'hover');
});

Inherited from ​

ts
MaplibreMap.removeFeatureState

removeImage() ​

ts
removeImage(id): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12593

Remove an image from a style. This can be an image from the style's original sprite or any images that have been added at runtime using Map.addImage.

Parameters ​

id ​

string

The ID of the image.

Returns ​

void

Example ​

ts
// If an image with the ID 'cat' exists in
// the style's sprite, remove it.
if (map.hasImage('cat')) map.removeImage('cat');

Inherited from ​

ts
MaplibreMap.removeImage

removeLayer() ​

Call Signature ​

ts
removeLayer(layer): this;

Defined in: packages/core-libre/src/map/gmap.ts:321

移除图层:支持 GLayer 实例或原生图层 id

Parameters ​
layer ​

GLayer

Returns ​

this

Overrides ​
ts
MaplibreMap.removeLayer

Call Signature ​

ts
removeLayer(id): this;

Defined in: packages/core-libre/src/map/gmap.ts:322

移除图层:支持 GLayer 实例或原生图层 id

Parameters ​
id ​

string

Returns ​

this

Overrides ​
ts
MaplibreMap.removeLayer

removeSource() ​

ts
removeSource(id): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12424

Removes a source from the map's style.

Parameters ​

id ​

string

The ID of the source to remove.

Returns ​

this

Example ​

ts
map.removeSource('bathymetry-data');

Inherited from ​

ts
MaplibreMap.removeSource

removeSprite() ​

ts
removeSprite(id): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12906

Removes the sprite from the map's style. Fires the style event.

Parameters ​

id ​

string

The ID of the sprite to remove. If the sprite is declared as a single URL, the ID must be "default".

Returns ​

this

Example ​

ts
map.removeSprite('sprite-two');
map.removeSprite('default');

Inherited from ​

ts
MaplibreMap.removeSprite

resetNorth() ​

ts
resetNorth(options?, eventData?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8883

Rotates the map so that north is up (0° bearing), with an animated transition.

Triggers the following events: movestart, moveend, and rotate.

Parameters ​

options? ​

AnimationOptions

Options object

eventData? ​

any

Additional properties to be added to event objects of events triggered by this method.

Returns ​

this

Inherited from ​

ts
MaplibreMap.resetNorth

resetNorthPitch() ​

ts
resetNorthPitch(options?, eventData?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8892

Rotates and pitches the map so that north is up (0° bearing) and pitch and roll are 0°, with an animated transition.

Triggers the following events: movestart, move, moveend, pitchstart, pitch, pitchend, rollstart, roll, rollend, and rotate.

Parameters ​

options? ​

AnimationOptions

Options object

eventData? ​

any

Additional properties to be added to event objects of events triggered by this method.

Returns ​

this

Inherited from ​

ts
MaplibreMap.resetNorthPitch

resize() ​

ts
resize(eventData?, constrainTransform?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11621

Resizes the map according to the dimensions of its container element.

Checks if the map container size changed and updates the map if it has changed. This method must be called after the map's container is resized programmatically or when the map is shown after being initially hidden with CSS.

Triggers the following events: movestart, move, moveend, and resize.

Parameters ​

eventData? ​

any

Additional properties to be passed to movestart, move, resize, and moveend events that get triggered as a result of resize. This can be useful for differentiating the source of an event (for example, user-initiated or programmatically-triggered events).

constrainTransform? ​

boolean

Returns ​

this

Example ​

Resize the map when the map container is shown after being initially hidden with CSS.

ts
let mapDiv = document.getElementById('map');
if (mapDiv.style.visibility === true) map.resize();

Inherited from ​

ts
MaplibreMap.resize

rotateTo() ​

ts
rotateTo(
   bearing, 
   options?, 
   eventData?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8874

Rotates the map to the specified bearing, with an animated transition. The bearing is the compass direction that is "up"; for example, a bearing of 90° orients the map so that east is up.

Triggers the following events: movestart, moveend, and rotate.

Parameters ​

bearing ​

number

The desired bearing.

options? ​

EaseToOptions

Options object

eventData? ​

any

Additional properties to be added to event objects of events triggered by this method.

Returns ​

this

Inherited from ​

ts
MaplibreMap.rotateTo

setAnisotropicFilterPitch() ​

ts
setAnisotropicFilterPitch(anisotropicFilterPitch?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11816

Sets the map's anisotropic filter pitch or reverts it to its default.

A ErrorEvent event will be fired if anisotropicFilterPitch is out of bounds.

Parameters ​

anisotropicFilterPitch? ​

number | null

The pitch above which to apply anisotropic filtering to the map's raster layers (0-180). If null or undefined is provided, the function reverts to the default pitch threshold (20).

Returns ​

this

Example ​

ts
map.setAnisotropicFilterPitch(85);

Inherited from ​

ts
MaplibreMap.setAnisotropicFilterPitch

setBase() ​

ts
setBase(base, config?): void;

Defined in: packages/core-libre/src/map/gmap.ts:355

切换底图(设置新 style,随后自动重装本库管理的图层)

Parameters ​

base ​

BaseInput

config? ​

BaseLayerConfig

Returns ​

void


setBearing() ​

ts
setBearing(bearing, eventData?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8841

Sets the map's bearing (rotation). The bearing is the compass direction that is "up"; for example, a bearing of 90° orients the map so that east is up.

Equivalent to jumpTo({bearing: bearing}).

Triggers the following events: movestart, moveend, and rotate.

Parameters ​

bearing ​

number

The desired bearing.

eventData? ​

any

Additional properties to be added to event objects of events triggered by this method.

Returns ​

this

Example ​

Rotate the map to 90 degrees

ts
map.setBearing(90);

Inherited from ​

ts
MaplibreMap.setBearing

setCenter() ​

ts
setCenter(...args): this;

Defined in: packages/core-libre/src/map/gmap.ts:177

Sets the map's geographical centerpoint. Equivalent to jumpTo({center: center}).

Triggers the following events: movestart and moveend.

Parameters ​

args ​

...[LngLatLike, any]

Returns ​

this

Example ​

ts
map.setCenter([-74, 38]);

Overrides ​

ts
MaplibreMap.setCenter

setCenterClampedToGround() ​

ts
setCenterClampedToGround(centerClampedToGround): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8678

Sets the value of centerClampedToGround.

If true, the elevation of the center point will automatically be set to the terrain elevation (or zero if terrain is not enabled). If false, the elevation of the center point will default to sea level and will not automatically update. Defaults to true. Needs to be set to false to keep the camera above ground when pitch > 90 degrees.

Parameters ​

centerClampedToGround ​

boolean

Returns ​

void

Inherited from ​

ts
MaplibreMap.setCenterClampedToGround

setCenterElevation() ​

ts
setCenterElevation(elevation, eventData?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8660

Sets the elevation of the map's center point, in meters above sea level. Equivalent to jumpTo({elevation: elevation}).

Triggers the following events: movestart and moveend.

Parameters ​

elevation ​

number

The elevation to set, in meters above sea level.

eventData? ​

any

Additional properties to be added to event objects of events triggered by this method.

Returns ​

this

Inherited from ​

ts
MaplibreMap.setCenterElevation

setCursor() ​

ts
setCursor(cursor): void;

Defined in: packages/core-libre/src/map/gmap.ts:401

设置鼠标样式;'default' 视为恢复默认

Parameters ​

cursor ​

string

Returns ​

void


setEventedParent() ​

ts
setEventedParent(parent?, data?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:866

Bubble all events fired by this instance of Evented to this parent instance of Evented.

Parameters ​

parent? ​

Evented | null

data? ​

any

Returns ​

this

Inherited from ​

ts
MaplibreMap.setEventedParent

setFeatureState() ​

ts
setFeatureState(feature, state): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13004

Sets the state of a feature. A feature's state is a set of user-defined key-value pairs that are assigned to a feature at runtime. When using this method, the state object is merged with any existing key-value pairs in the feature's state. Features are identified by their feature.id attribute, which can be any number or string.

This method can only be used with sources that have a feature.id attribute. The feature.id attribute can be defined in three ways:

  • For vector or GeoJSON sources, including an id attribute in the original data file.
  • For vector or GeoJSON sources, using the promoteId option at the time the source is defined.
  • For GeoJSON sources, using the generateId option to auto-assign an id based on the feature's index in the source data. If you change feature data using map.getSource('some id').setData(..), you may need to re-apply state taking into account updated id values.

!!! note You can use the feature-state expression to access the values in a feature's state object for the purposes of styling.

Parameters ​

feature ​

FeatureIdentifier

Feature identifier. Feature objects returned from Map.queryRenderedFeatures or event handlers can be used as feature identifiers.

state ​

any

A set of key-value pairs. The values should be valid JSON types.

Returns ​

this

Example ​

ts
// When the mouse moves over the `my-layer` layer, update
// the feature state for the feature under the mouse
map.on('mousemove', 'my-layer', (e) => {
  if (e.features.length > 0) {
    map.setFeatureState({
      source: 'my-source',
      sourceLayer: 'my-source-layer',
      id: e.features[0].id,
    }, {
      hover: true
    });
  }
});

See ​

Create a hover effect

Inherited from ​

ts
MaplibreMap.setFeatureState

setFilter() ​

ts
setFilter(
   layerId, 
   filter?, 
   options?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12812

Sets the filter for the specified style layer.

Filters control which features a style layer renders from its source. Any feature for which the filter expression evaluates to true will be rendered on the map. Those that are false will be hidden.

Use setFilter to show a subset of your source data.

To clear the filter, pass null or undefined as the second parameter.

Parameters ​

layerId ​

string

The ID of the layer to which the filter will be applied.

filter? ​

FilterSpecification | null

The filter, conforming to the MapLibre Style Specification's filter definition. If null or undefined is provided, the function removes any existing filter from the layer.

options? ​

StyleSetterOptions

Options object.

Returns ​

this

Examples ​

Display only features with the 'name' property 'USA'

ts
map.setFilter('my-layer', ['==', ['get', 'name'], 'USA']);

Display only features with five or more 'available-spots'

ts
map.setFilter('bike-docks', ['>=', ['get', 'available-spots'], 5]);

Remove the filter for the 'bike-docks' style layer

ts
map.setFilter('bike-docks', null);

See ​

Create a timeline animation

Inherited from ​

ts
MaplibreMap.setFilter

setGlobalStateProperty() ​

ts
setGlobalStateProperty(propertyName, value): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11531

Sets a global state property that can be retrieved with the global-state expression. If the value is null, it resets the property to its default value defined in the state style property.

Parameters ​

propertyName ​

string

The name of the state property to set.

value ​

any

The value of the state property to set.

Returns ​

this

Inherited from ​

ts
MaplibreMap.setGlobalStateProperty

setGlyphs() ​

ts
setGlyphs(glyphsUrl, options?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12877

Sets the value of the style's glyphs property. Pass a falsy value (null or undefined) to unset glyphs. * *

Parameters ​

glyphsUrl ​

string | null | undefined

Glyph URL to set. Must conform to the MapLibre Style Specification. *

options? ​

StyleSetterOptions

Options object. *

Returns ​

this

Example ​

Inherited from ​

ts
MaplibreMap.setGlyphs

setLayerZoomRange() ​

ts
setLayerZoomRange(
   layerId, 
   minzoom, 
   maxzoom): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12778

Sets the zoom extent for the specified style layer. The zoom extent includes the minimum zoom level and maximum zoom level) at which the layer will be rendered.

!!! note For style layers using vector sources, style layers cannot be rendered at zoom levels lower than the minimum zoom level of the source layer because the data does not exist at those zoom levels. If the minimum zoom level of the source layer is higher than the minimum zoom level defined in the style layer, the style layer will not be rendered at all zoom levels in the zoom range.

Parameters ​

layerId ​

string

The ID of the layer to which the zoom extent will be applied.

minzoom ​

number

The minimum zoom to set (0-24).

maxzoom ​

number

The maximum zoom to set (0-24).

Returns ​

this

Example ​

ts
map.setLayerZoomRange('my-layer', 2, 5);

Inherited from ​

ts
MaplibreMap.setLayerZoomRange

setLayoutProperty() ​

ts
setLayoutProperty(
   layerId, 
   name, 
   value, 
   options?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12857

Sets the value of a layout property in the specified style layer.

Parameters ​

layerId ​

string

The ID of the layer to set the layout property in.

name ​

string

The name of the layout property to set.

value ​

any

The value of the layout property. Must be of a type appropriate for the property, as defined in the MapLibre Style Specification.

options? ​

StyleSetterOptions

The options object.

Returns ​

this

Example ​

ts
map.setLayoutProperty('my-layer', 'visibility', 'none');

Inherited from ​

ts
MaplibreMap.setLayoutProperty

setLight() ​

ts
setLight(light, options?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12938

Sets the any combination of light values.

Parameters ​

light ​

LightSpecification

Light properties to set. Must conform to the MapLibre Style Specification.

options? ​

StyleSetterOptions

Options object.

Returns ​

this

Example ​

ts
let layerVisibility = map.getLayoutProperty('my-layer', 'visibility');

Inherited from ​

ts
MaplibreMap.setLight

setMaxBounds() ​

ts
setMaxBounds(bounds?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11697

Sets or clears the map's geographical bounds.

Pan and zoom operations are constrained within these bounds. If a pan or zoom is performed that would display regions outside these bounds, the map will instead display a position and zoom level as close as possible to the operation's request while still remaining within the bounds.

Parameters ​

bounds? ​

LngLatBoundsLike | null

The maximum bounds to set. If null or undefined is provided, the function removes the map's maximum bounds.

Returns ​

this

Example ​

Define bounds that conform to the LngLatBoundsLike object as set the max bounds.

ts
let bounds = [
  [-74.04728, 40.68392], // [west, south]
  [-73.91058, 40.87764]  // [east, north]
];
map.setMaxBounds(bounds);

Inherited from ​

ts
MaplibreMap.setMaxBounds

setMaxPitch() ​

ts
setMaxPitch(maxPitch?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11784

Sets or clears the map's maximum pitch. If the map's current pitch is higher than the new maximum, the map will pitch to the new maximum and trigger the following events: movestart, move, moveend, pitchstart, pitch, and pitchend.

A ErrorEvent event will be fired if maxPitch is out of bounds.

Parameters ​

maxPitch? ​

number | null

The maximum pitch to set (0-180). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project. If null or undefined is provided, the function removes the current maximum pitch (sets it to 60).

Returns ​

this

Inherited from ​

ts
MaplibreMap.setMaxPitch

setMaxZoom() ​

ts
setMaxZoom(maxZoom?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11744

Sets or clears the map's maximum zoom level. If the map's current zoom level is higher than the new maximum, the map will zoom to the new maximum and trigger the following events: movestart, move, moveend, zoomstart, zoom, and zoomend.

A ErrorEvent event will be fired if minZoom is out of bounds.

Parameters ​

maxZoom? ​

number | null

The maximum zoom level to set. If null or undefined is provided, the function removes the current maximum zoom (sets it to 22).

Returns ​

this

Example ​

ts
map.setMaxZoom(18.75);

Inherited from ​

ts
MaplibreMap.setMaxZoom

setMinPitch() ​

ts
setMinPitch(minPitch?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11766

Sets or clears the map's minimum pitch. If the map's current pitch is lower than the new minimum, the map will pitch to the new minimum and trigger the following events: movestart, move, moveend, pitchstart, pitch, and pitchend.

A ErrorEvent event will be fired if minPitch is out of bounds.

Parameters ​

minPitch? ​

number | null

The minimum pitch to set (0-180). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project. If null or undefined is provided, the function removes the current minimum pitch (i.e. sets it to 0).

Returns ​

this

Inherited from ​

ts
MaplibreMap.setMinPitch

setMinZoom() ​

ts
setMinZoom(minZoom?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11718

Sets or clears the map's minimum zoom level. If the map's current zoom level is lower than the new minimum, the map will zoom to the new minimum and trigger the following events: movestart, move, moveend, zoomstart, zoom, and zoomend.

It is not always possible to zoom out and reach the set minZoom. Other factors such as map height may restrict zooming. For example, if the map is 512px tall it will not be possible to zoom below zoom 0 no matter what the minZoom is set to.

A ErrorEvent event will be fired if minZoom is out of bounds.

Parameters ​

minZoom? ​

number | null

The minimum zoom level to set (-2 - 24). If null or undefined is provided, the function removes the current minimum zoom (i.e. sets it to -2).

Returns ​

this

Example ​

ts
map.setMinZoom(12.25);

Inherited from ​

ts
MaplibreMap.setMinZoom

setPadding() ​

ts
setPadding(padding, eventData?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8863

Sets the padding in pixels around the viewport.

Equivalent to jumpTo({padding: padding}).

Triggers the following events: movestart and moveend.

Parameters ​

padding ​

PaddingOptions

The desired padding.

eventData? ​

any

Additional properties to be added to event objects of events triggered by this method.

Returns ​

this

Example ​

Sets a left padding of 300px, and a top padding of 50px

ts
map.setPadding({ left: 300, top: 50 });

Inherited from ​

ts
MaplibreMap.setPadding

setPaintProperty() ​

ts
setPaintProperty(
   layerId, 
   name, 
   value, 
   options?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12836

Sets the value of a paint property in the specified style layer.

Parameters ​

layerId ​

string

The ID of the layer to set the paint property in.

name ​

string

The name of the paint property to set.

value ​

any

The value of the paint property to set. Must be of a type appropriate for the property, as defined in the MapLibre Style Specification. Pass null to unset the existing value.

options? ​

StyleSetterOptions

Options object.

Returns ​

this

Example ​

ts
map.setPaintProperty('my-layer', 'fill-color', '#faafee');

See ​

Inherited from ​

ts
MaplibreMap.setPaintProperty

setPitch() ​

ts
setPitch(pitch, eventData?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8917

Sets the map's pitch (tilt). Equivalent to jumpTo({pitch: pitch}).

Triggers the following events: movestart, moveend, pitchstart, and pitchend.

Parameters ​

pitch ​

number

The pitch to set, measured in degrees away from the plane of the screen (0-60).

eventData? ​

any

Additional properties to be added to event objects of events triggered by this method.

Returns ​

this

Inherited from ​

ts
MaplibreMap.setPitch

setPixelRatio() ​

ts
setPixelRatio(pixelRatio): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11656

Sets the map's pixel ratio. This allows to override devicePixelRatio. After this call, the canvas' width attribute will be container.clientWidth * pixelRatio and its height attribute will be container.clientHeight * pixelRatio. Set this to null to disable devicePixelRatio override. Note that the pixel ratio actually applied may be lower to respect maxCanvasSize.

Parameters ​

pixelRatio ​

number

The pixel ratio.

Returns ​

void

Inherited from ​

ts
MaplibreMap.setPixelRatio

setProjection() ​

ts
setProjection(projection): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13270

Sets the ProjectionSpecification.

Parameters ​

projection ​

ProjectionSpecification

the projection specification to set

Returns ​

this

Inherited from ​

ts
MaplibreMap.setProjection

setRenderWorldCopies() ​

ts
setRenderWorldCopies(renderWorldCopies?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11849

Sets the state of renderWorldCopies.

Parameters ​

renderWorldCopies? ​

boolean | null

If true, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to false:

  • When the map is zoomed out far enough that a single representation of the world does not fill the map's entire container, there will be blank space beyond 180 and -180 degrees longitude.
  • Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the map and the other on the left edge of the map) at every zoom level.

undefined is treated as true, null is treated as false.

Returns ​

this

Example ​

ts
map.setRenderWorldCopies(true);

See ​

Render world copies

Inherited from ​

ts
MaplibreMap.setRenderWorldCopies

setRoll() ​

ts
setRoll(roll, eventData?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8932

Sets the map's roll angle. Equivalent to jumpTo({roll: roll}).

Triggers the following events: movestart, moveend, rollstart, and rollend.

Parameters ​

roll ​

number

The roll to set, measured in degrees about the camera boresight

eventData? ​

any

Additional properties to be added to event objects of events triggered by this method.

Returns ​

this

Inherited from ​

ts
MaplibreMap.setRoll

setSky() ​

ts
setSky(sky, options?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12956

Sets the value of style's sky properties.

Parameters ​

sky ​

SkySpecification

Sky properties to set. Must conform to the MapLibre Style Specification.

options? ​

StyleSetterOptions

Options object.

Returns ​

this

Example ​

ts
map.setSky({'atmosphere-blend': 1.0});

Inherited from ​

ts
MaplibreMap.setSky

setSourceTileLodParams() ​

ts
setSourceTileLodParams(
   maxZoomLevelsOnScreen, 
   tileCountMaxMinRatio, 
   sourceId?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12468

Change the tile Level of Detail behavior of the specified source. These parameters have no effect when pitch == 0, and the largest effect when the horizon is visible on screen.

Parameters ​

maxZoomLevelsOnScreen ​

number

The maximum number of distinct zoom levels allowed on screen at a time. There will generally be fewer zoom levels on the screen, the maximum can only be reached when the horizon is at the top of the screen. Increasing the maximum number of zoom levels causes the zoom level to decay faster toward the horizon.

tileCountMaxMinRatio ​

number

The ratio of the maximum number of tiles loaded (at high pitch) to the minimum number of tiles loaded. Increasing this ratio allows more tiles to be loaded at high pitch angles. If the ratio would otherwise be exceeded, the zoom level is reduced uniformly to keep the number of tiles within the limit.

sourceId? ​

string

The ID of the source to set tile LOD parameters for. All sources will be updated if unspecified. If sourceId is specified but a corresponding source does not exist, an error is thrown.

Returns ​

this

Example ​

ts
map.setSourceTileLodParams(4.0, 3.0, 'terrain');

See ​

Modify Level of Detail behavior

Inherited from ​

ts
MaplibreMap.setSourceTileLodParams

setSprite() ​

ts
setSprite(spriteUrl, options?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12926

Sets the value of the style's sprite property.

Parameters ​

spriteUrl ​

string | null

Sprite URL to set.

options? ​

StyleSetterOptions

Options object.

Returns ​

this

Example ​

ts
map.setSprite('YOUR_SPRITE_URL');

Inherited from ​

ts
MaplibreMap.setSprite

setStyle() ​

ts
setStyle(style, options?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12284

Updates the map's MapLibre style object with a new value.

If a style is already set when this is used and options.diff is set to true, the map renderer will attempt to compare the given style against the map's current state and perform only the changes necessary to make the map style match the desired state. Changes in sprites (images used for icons and patterns) and glyphs (fonts for label text) cannot be diffed. If the sprites or fonts used in the current style and the given style are different in any way, the map renderer will force a full update, removing the current style and building the given one from scratch.

Parameters ​

style ​

string | StyleSpecification | null

A JSON object conforming to the schema described in the MapLibre Style Specification, or a URL to such JSON.

options? ​

StyleSwapOptions & StyleOptions

The options object.

Returns ​

this

Example ​

ts
map.setStyle("https://demotiles.maplibre.org/style.json");

map.setStyle('https://demotiles.maplibre.org/style.json', {
  transformStyle: (previousStyle, nextStyle) => ({
      ...nextStyle,
      sources: {
          ...nextStyle.sources,
          // copy a source from previous style
          'osm': previousStyle.sources.osm
      },
      layers: [
          // background layer
          nextStyle.layers[0],
          // copy a layer from previous style
          previousStyle.layers[0],
          // other layers from the next style
          ...nextStyle.layers.slice(1).map(layer => {
              // hide the layers we don't need from demotiles style
              if (layer.id.startsWith('geolines')) {
                  layer.layout = {...layer.layout || {}, visibility: 'none'};
              // filter out US polygons
              } else if (layer.id.startsWith('coastline') || layer.id.startsWith('countries')) {
                  layer.filter = ['!=', ['get', 'ADM0_A3'], 'USA'];
              }
              return layer;
          })
      ]
  })
});

Inherited from ​

ts
MaplibreMap.setStyle

setTerrain() ​

ts
setTerrain(options): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12394

Loads a 3D terrain mesh, based on a "raster-dem" source.

Triggers the terrain event.

Parameters ​

options ​

TerrainSpecification | null

Options object.

Returns ​

this

Example ​

ts
map.setTerrain({ source: 'terrain' });

Inherited from ​

ts
MaplibreMap.setTerrain

setTransformConstrain() ​

ts
setTransformConstrain(constrain?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11864

Sets or clears the callback overriding how the map constrains the viewport's lnglat and zoom to respect the longitude and latitude bounds.

Parameters ​

constrain? ​

TransformConstrainFunction | null

A TransformConstrainFunction callback defining how the viewport should respect the bounds.

null clears the callback and reverts the constrain to the map transform's default constrain function.

Returns ​

this

Example ​

ts
function customTransformConstrain(lngLat, zoom) {
  return {center: lngLat, zoom: zoom ?? 0};
};
map.setTransformConstrain(customTransformConstrain);

See ​

Customize the map transform constrain

Inherited from ​

ts
MaplibreMap.setTransformConstrain

setTransformRequest() ​

ts
setTransformRequest(transformRequest): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12296

Updates the requestManager's transform request with a new function

Parameters ​

transformRequest ​

RequestTransformFunction | null

A callback run before the Map makes a request for an external URL. The callback can be used to modify the url, set headers, or set the credentials property for cross-origin requests. Expected to return an object with a url property and optionally headers and credentials properties

Returns ​

this

Example ​

ts
map.setTransformRequest((url: string, resourceType: string) => {});

Inherited from ​

ts
MaplibreMap.setTransformRequest

setVerticalFieldOfView() ​

ts
setVerticalFieldOfView(fov, eventData?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8804

Sets the map's vertical field of view, in degrees.

Triggers the following events: movestart, move, and moveend.

Parameters ​

fov ​

number

The vertical field of view to set, in degrees (0-180).

eventData? ​

any

Additional properties to be added to event objects of events triggered by this method.

Returns ​

this

Default Value ​

ts
36.87

Example ​

Change vertical field of view to 30 degrees

ts
map.setVerticalFieldOfView(30);

Inherited from ​

ts
MaplibreMap.setVerticalFieldOfView

setZoom() ​

ts
setZoom(zoom, eventData?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8730

Sets the map's zoom level. Equivalent to jumpTo({zoom: zoom}).

Triggers the following events: movestart, move, moveend, zoomstart, zoom, and zoomend.

Parameters ​

zoom ​

number

The zoom level to set (0-20).

eventData? ​

any

Additional properties to be added to event objects of events triggered by this method.

Returns ​

this

Example ​

Zoom to the zoom level 5 without an animated transition

ts
map.setZoom(5);

Inherited from ​

ts
MaplibreMap.setZoom

setZoomAndCenter() ​

ts
setZoomAndCenter(zoom, center): void;

Defined in: packages/core-libre/src/map/gmap.ts:395

同时设置层级与中心(经纬度)

Parameters ​

zoom ​

number

center ​

LngLatLike

Returns ​

void


setZoomSnap() ​

ts
setZoomSnap(snap): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8818

Sets the map's zoom snap level.

Parameters ​

snap ​

number

The zoom snap level to set.

Returns ​

this

Inherited from ​

ts
MaplibreMap.setZoomSnap

snapToNorth() ​

ts
snapToNorth(options?, eventData?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8902

Snaps the map so that north is up (0° bearing), if the current bearing is close enough to it (i.e. within the bearingSnap threshold).

Triggers the following events: movestart, moveend, and rotate.

Parameters ​

options? ​

AnimationOptions

Options object

eventData? ​

any

Additional properties to be added to event objects of events triggered by this method.

Returns ​

this

Inherited from ​

ts
MaplibreMap.snapToNorth

stop() ​

ts
stop(): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:9190

Stops any animated transition underway.

Returns ​

this

Inherited from ​

ts
MaplibreMap.stop

switchBase() ​

ts
switchBase(base, config?): void;

Defined in: packages/core-libre/src/map/gmap.ts:374

切换底图(switchBase 为 setBase 的别名,对齐 core 命名)

Parameters ​

base ​

BaseInput

config? ​

BaseLayerConfig

Returns ​

void


toWGS84() ​

ts
toWGS84(ll): [number, number];

Defined in: packages/core-libre/src/map/gmap.ts:139

当前基准面 → WGS-84(把地图空间坐标还原为 WGS-84)

Parameters ​

ll ​

LngLatLike

Returns ​

[number, number]


triggerRepaint() ​

ts
triggerRepaint(): void;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:13196

Trigger the rendering of a single frame. Use this method with custom layers to repaint the map when the layer changes. Calling this multiple times before the next frame is rendered will still result in only a single frame being rendered.

Returns ​

void

Example ​

ts
map.triggerRepaint();

See ​

Inherited from ​

ts
MaplibreMap.triggerRepaint

unproject() ​

ts
unproject(point): LngLat;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:11892

Returns a LngLat representing geographical coordinates that correspond to the specified pixel coordinates.

Parameters ​

point ​

PointLike

The pixel coordinates to unproject.

Returns ​

LngLat

The LngLat corresponding to point.

Example ​

ts
map.on('click', (e) => {
  // When the map is clicked, get the geographic coordinate.
  let coordinate = map.unproject(e.point);
});

Inherited from ​

ts
MaplibreMap.unproject

updateImage() ​

ts
updateImage(id, image): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12543

Update an existing image in a style. This image can be displayed on the map like any other icon in the style's sprite using the image's ID with icon-image, background-pattern, fill-pattern, or line-pattern.

An ErrorEvent will be fired if the image parameter is invalid.

Parameters ​

id ​

string

The ID of the image.

image ​

| HTMLImageElement | ImageBitmap | ImageData | StyleImageInterface | { data: | Uint8Array<ArrayBufferLike> | Uint8ClampedArray<ArrayBufferLike>; height: number; width: number; }

The image as an HTMLImageElement, ImageData, ImageBitmap or object with width, height, and data properties with the same format as ImageData.

Returns ​

this

Example ​

ts
// If an image with the ID 'cat' already exists in the style's sprite,
// replace that image with a new image, 'other-cat-icon.png'.
if (map.hasImage('cat')) map.updateImage('cat', './other-cat-icon.png');

Inherited from ​

ts
MaplibreMap.updateImage

whenReady() ​

ts
whenReady(cb): void;

Defined in: packages/core-libre/src/map/gmap.ts:299

在 style 就绪后执行(已就绪则立即执行)

Parameters ​

cb ​

() => void

Returns ​

void


zoomIn() ​

ts
zoomIn(options?, eventData?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8764

Incrementally increases the map's zoom level by 1, first snapping to the nearest zoomSnap increment.

Triggers the following events: movestart, move, moveend, zoomstart, zoom, and zoomend.

Parameters ​

options? ​

AnimationOptions

Options object

eventData? ​

any

Additional properties to be added to event objects of events triggered by this method.

Returns ​

this

Example ​

Zoom the map in one level with a custom animation duration

ts
map.zoomIn({duration: 1000});

Inherited from ​

ts
MaplibreMap.zoomIn

zoomOut() ​

ts
zoomOut(options?, eventData?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8778

Decreases the map's zoom level by 1, first snapping to the nearest zoomSnap increment.

Triggers the following events: movestart, move, moveend, zoomstart, zoom, and zoomend.

Parameters ​

options? ​

AnimationOptions

Options object

eventData? ​

any

Additional properties to be added to event objects of events triggered by this method.

Returns ​

this

Example ​

Zoom the map out one level with a custom animation offset

ts
map.zoomOut({offset: [80, 60]});

Inherited from ​

ts
MaplibreMap.zoomOut

zoomTo() ​

ts
zoomTo(
   zoom, 
   options?, 
   eventData?): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:8750

Zooms the map to the specified zoom level, with an animated transition.

Triggers the following events: movestart, move, moveend, zoomstart, zoom, and zoomend.

Parameters ​

zoom ​

number

The zoom level to transition to.

options? ​

EaseToOptions | null

Options object

eventData? ​

any

Additional properties to be added to event objects of events triggered by this method.

Returns ​

this

Example ​

ts
// Zoom to the zoom level 5 without an animated transition
map.zoomTo(5);
// Zoom to the zoom level 8 with an animated transition
map.zoomTo(8, {
  duration: 2000,
  offset: [100, 50]
});

Inherited from ​

ts
MaplibreMap.zoomTo

Events ​

off() ​

Call Signature ​

ts
off<T>(
   type, 
   layer, 
   listener): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12098

Removes an event listener for events previously added with {@link Map.on}.

Type Parameters ​
T ​

T extends keyof MapLayerEventType

Parameters ​
type ​

T

The event type previously used to install the listener.

layer ​

string

The layer ID or listener previously used to install the listener.

listener ​

(ev) => void

The function previously installed as a listener.

Returns ​

this

Inherited from ​
ts
MaplibreMap.off

Call Signature ​

ts
off<T>(
   type, 
   layers, 
   listener): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12107

Overload of the off method that allows to remove an event created with multiple layers. Provide the same layer IDs as to on or once, when the listener was registered.

Type Parameters ​
T ​

T extends keyof MapLayerEventType

Parameters ​
type ​

T

The type of the event.

layers ​

string[]

The layer IDs previously used to install the listener.

listener ​

(ev) => void

The function previously installed as a listener.

Returns ​

this

Inherited from ​
ts
MaplibreMap.off

Call Signature ​

ts
off<T>(type, listener): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12114

Overload of the off method that allows to remove an event created without specifying a layer.

Type Parameters ​
T ​

T extends keyof MapEventType

Parameters ​
type ​

T

The type of the event.

listener ​

(ev) => void

The function previously installed as a listener.

Returns ​

this

Inherited from ​
ts
MaplibreMap.off

Call Signature ​

ts
off(type, listener): this;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12121

Overload of the off method that allows to remove an event created without specifying a layer.

Parameters ​
type ​

string

The type of the event.

listener ​

Listener

The function previously installed as a listener.

Returns ​

this

Inherited from ​
ts
MaplibreMap.off

on() ​

Call Signature ​

ts
on<T>(
   type, 
   layer, 
   listener): Subscription;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12028

Adds a listener for events of a specified type, optionally limited to features in a specified style layer(s). See MapEventType and MapLayerEventType for a full list of events and their description.

EventCompatible with layerId
mousedownyes
mouseupyes
mouseoveryes
mouseoutyes
mousemoveyes
mouseenteryes (required)
mouseleaveyes (required)
clickyes
dblclickyes
contextmenuyes
touchstartyes
touchendyes
touchcancelyes
wheel
resize
remove
touchmove
movestart
move
moveend
dragstart
drag
dragend
zoomstart
zoom
zoomend
rotatestart
rotate
rotateend
pitchstart
pitch
pitchend
boxzoomstart
boxzoomend
boxzoomcancel
webglcontextlost
webglcontextrestored
load
render
idle
error
data
styledata
sourcedata
dataloading
styledataloading
sourcedataloading
styleimagemissing
dataabort
sourcedataabort
Type Parameters ​
T ​

T extends keyof MapLayerEventType

Parameters ​
type ​

T

The event type to listen for. Events compatible with the optional layerId parameter are triggered when the cursor enters a visible portion of the specified layer from outside that layer or outside the map canvas.

layer ​

string

The ID of a style layer or a listener if no ID is provided. Event will only be triggered if its location is within a visible feature in this layer. The event will have a features property containing an array of the matching features. If layer is not supplied, the event will not have a features property. Please note that many event types are not compatible with the optional layer parameter.

listener ​

(ev) => void

The function to be called when the event is fired.

Returns ​

Subscription

Examples ​
ts
// Set an event listener that will fire
// when the map has finished loading
map.on('load', () => {
  // Once the map has finished loading,
  // add a new layer
  map.addLayer({
    id: 'points-of-interest',
    source: {
      type: 'vector',
      url: 'https://maplibre.org/maplibre-style-spec/'
    },
    'source-layer': 'poi_label',
    type: 'circle',
    paint: {
      // MapLibre Style Specification paint properties
    },
    layout: {
      // MapLibre Style Specification layout properties
    }
  });
});
ts
// Set an event listener that will fire
// when a feature on the countries layer of the map is clicked
map.on('click', 'countries', (e) => {
  new Popup()
    .setLngLat(e.lngLat)
    .setHTML(`Country name: ${e.features[0].properties.name}`)
    .addTo(map);
});
See ​
Inherited from ​
ts
MaplibreMap.on

Call Signature ​

ts
on<T>(
   type, 
   layerIds, 
   listener): Subscription;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12036

Overload of the on method that allows to listen to events specifying multiple layers.

Type Parameters ​
T ​

T extends keyof MapLayerEventType

Parameters ​
type ​

T

The type of the event.

layerIds ​

string[]

The array of style layer IDs.

listener ​

(ev) => void

The listener callback.

Returns ​

Subscription

Inherited from ​
ts
MaplibreMap.on

Call Signature ​

ts
on<T>(type, listener): Subscription;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12043

Overload of the on method that allows to listen to events without specifying a layer.

Type Parameters ​
T ​

T extends keyof MapEventType

Parameters ​
type ​

T

The type of the event.

listener ​

(ev) => void

The listener callback.

Returns ​

Subscription

Inherited from ​
ts
MaplibreMap.on

Call Signature ​

ts
on(type, listener): Subscription;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12050

Overload of the on method that allows to listen to events without specifying a layer.

Parameters ​
type ​

string

The type of the event.

listener ​

Listener

The listener callback.

Returns ​

Subscription

Inherited from ​
ts
MaplibreMap.on

once() ​

Call Signature ​

ts
once<T>(
   type, 
   layer, 
listener?): GMap | Promise<MapLayerEventType[T] & Object>;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12067

Adds a listener that will be called only once to a specified event type, optionally limited to features in a specified style layer.

Type Parameters ​
T ​

T extends keyof MapLayerEventType

Parameters ​
type ​

T

The event type to listen for; one of 'mousedown', 'mouseup', 'click', 'dblclick', 'mousemove', 'mouseenter', 'mouseleave', 'mouseover', 'mouseout', 'contextmenu', 'touchstart', 'touchend', or 'touchcancel'. mouseenter and mouseover events are triggered when the cursor enters a visible portion of the specified layer from outside that layer or outside the map canvas. mouseleave and mouseout events are triggered when the cursor leaves a visible portion of the specified layer, or leaves the map canvas.

layer ​

string

The ID of a style layer or a listener if no ID is provided. Only events whose location is within a visible feature in this layer will trigger the listener. The event will have a features property containing an array of the matching features.

listener? ​

(ev) => void

The function to be called when the event is fired.

Returns ​

GMap | Promise<MapLayerEventType[T] & Object>

this if listener is provided, promise otherwise to allow easier usage of async/await

Inherited from ​
ts
MaplibreMap.once

Call Signature ​

ts
once<T>(
   type, 
   layerIds, 
listener?): GMap | Promise<any>;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12075

Overload of the once method that allows to listen to events specifying multiple layers.

Type Parameters ​
T ​

T extends keyof MapLayerEventType

Parameters ​
type ​

T

The type of the event.

layerIds ​

string[]

The array of style layer IDs.

listener? ​

(ev) => void

The listener callback.

Returns ​

GMap | Promise<any>

Inherited from ​
ts
MaplibreMap.once

Call Signature ​

ts
once<T>(type, listener?): GMap | Promise<any>;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12082

Overload of the once method that allows to listen to events without specifying a layer.

Type Parameters ​
T ​

T extends keyof MapEventType

Parameters ​
type ​

T

The type of the event.

listener? ​

(ev) => void

The listener callback.

Returns ​

GMap | Promise<any>

Inherited from ​
ts
MaplibreMap.once

Call Signature ​

ts
once(type, listener?): GMap | Promise<any>;

Defined in: node_modules/.pnpm/maplibre-gl@5.24.0/node_modules/maplibre-gl/dist/maplibre-gl.d.ts:12089

Overload of the once method that allows to listen to events without specifying a layer.

Parameters ​
type ​

string

The type of the event.

listener? ​

Listener

The listener callback.

Returns ​

GMap | Promise<any>

Inherited from ​
ts
MaplibreMap.once