Add a new layer below labels

By utilizing the second parameter of the addLayer function in the SDK-JS API, you can enhance the accuracy of adding a new layer beneath the labels or any other desire layer. This allows for more precise placement and control over the layer’s position in relation to the rest of the map layers.



Learn more

In this example, we show how to find the Id of the first symbol layer in the map style.

Sometimes, we want to get the id of a layer other than the first symbol layer. For example, the Outdoor style has contour line labels below some polygons (intentionally cartographic hack), but we don’t want to add our layer before the contour line labels.

To find the id of the layer that will be used before my visualization layer you can search for it directly in the style json or more easily using the Customize tool.

  1. Go to MapTiler Cloud

  2. Select the map you are using in your application

  3. Click the Customize button

  4. Go to layer - Verticality and find the layer

  5. Click at the layer and open JSON editor ( {} )

  6. Copy layer id e.g. “River labels”

MapTiler Customize get layer ID

Related examples

An extension of MapLibre GL JS