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

moveLayer

Quick answer

moveLayer ( id : string , beforeId? : string ): this

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

moveLayer(id: string, beforeId?: string): this

Defined in: ui/map.ts:3559

Moves a layer to a different z-position.

Parameters

Parameter Type Description
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.

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


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/move-layer.html
Cite this page

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