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.
-
Go to MapTiler Cloud
-
Select the map you are using in your application
-
Click the Customize button
-
Go to layer - Verticality and find the layer
-
Click at the layer and open JSON editor ( {} )
-
Copy layer id e.g. “River labels”