Atlaslog
Atlaslog / MapLibre GL JS / API / getLayer
MapLibre GL JS · API reference

getLayer

Quick answer

getLayer ( id : string ): StyleLayer

Last verified 2026-11-03 · MapLibre GL JS 4.x · Cite this page
Runnable examplesChinese noteAll API topics
getLayer()

getLayer(id: string): StyleLayer

Defined in: ui/map.ts:3596

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

Parameters

Parameter Type Description
id string The ID of the layer to get.

Returns

StyleLayer

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

Example

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

See


TutorialsAPI index
English reference text adapted from the official MapLibre GL JS documentation, © MapLibre contributors, licensed under BSD-3-Clause.
Original page: https://maplibre.org/maplibre-gl-js/docs/API/classes/Map/ · Chinese note: /maplibre/api/get-layer.html
Cite this page

Atlaslog (2026). getLayer. https://www.jingweizhi.com/en/maplibre/api/get-layer.html (accessed 2026-11-03).