Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapbox: is it possible to update layer hierarchy?

Tags:

mapbox

I have a Mapbox with my own layers, says labels of towns and landmarks...

say I want to highlight one specific landmark and I want to move its z-index higher because otherwise, it would overlap with some other elements...

Can I use map.setLayoutProperty or is there anything else that I can do?

like image 203
Francesco Avatar asked Dec 03 '18 17:12

Francesco


People also ask

How do I add a layer to Mapbox?

Click the Type option, and then choose the Symbol layer option so you can create a layer with markers.

What are layers in Mapbox?

The type of layer is specified by the "type" property, and must be one of background , fill , line , symbol , raster , circle , fill-extrusion , heatmap , hillshade , sky . Except for layers of the background or sky types, each layer must refer to a source.


1 Answers

If I got your question correctly, you're looking for a way to change z-index of some layer above another layer. (not some feature above another feature). Here it the way:

https://www.mapbox.com/mapbox-gl-js/api/#map#movelayer

map.moveLayer(yourLandmarkLayerId, someAnotheLayerId);

If you would like just to move landmark layer to top of layer hierarchy:

map.moveLayer(yourLandmarkLayerId);

P.S. For moving layer, you should know it's ID:

var layers = map.getStyle().layers;
var layerId = layers[i].id;
like image 72
Yurii Bratchuk Avatar answered Nov 18 '22 03:11

Yurii Bratchuk