Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find all layers in Mapboxgl ? Ultimately I want to show custom layer only on water and not on land

Tags:

I created a custom circle layer. I want to show this layer only on water and not on land. I managed to do the opposite (ie: showing the layer on land and not on water) using below command. Refer this image for better understanding

map.moveLayer('polygon','water');

Now I need to know the land layer which is used by mapboxgl so that I can call function map.moveLayer('polygon','land'); to achieve what i want.

I need help to find the different layers present in the mapboxgl-streets map. But unfortunately, Mapboxgl doesn't have map.eachLayer function.

like image 584
Prasanna Elangovan Avatar asked Mar 23 '17 14:03

Prasanna Elangovan


People also ask

How do I get layers from Mapbox?

You can find a source layer's name in the Mapbox Studio Tileset explorer: Visit your Tilesets page. Click the name of one of your tilesets to open Tileset explorer. You will see the tileset's source layers listed under Vector layers.

What are layers in Mapbox?

A symbol layer is a layer in which icons or text are added to a Mapbox map. To mark the location of a geographical point in a symbol layer, you can add icons, text, or both icons and text.

How do I change the color of my Mapbox?

Mapbox will open a design window where you can adjust your chosen style. On the left side you will find map elements, where you can change colors and other properties. If you don't want to adjust anything just click on 'Go back' arrow at the top left.

How to get each layer name of a map in mapboxgl?

But unfortunately, Mapboxgl doesn't have map.eachLayer function. You can use the Map#getStyle method to get a serialized representation of the entire style including the layers. It depends on the map style you're using. In general, you either have to look at its source or load it in Mapbox Studio to identify the correct layer name.

What are the different layer types available in Mapbox?

Mapbox supports a lot of different layer types including background, fill, line, symbol, raster, circle, fill-extrusion, heatmap, hillshade, and sky. It is beyond the scope of this guide to cover all of these layer types, but this guide will focus on the what you will be most likely to use, fill, line, symbol ,and circle.

How do I enable and disable two different map layers in Mapbox?

This example adds a clickable interface that allows a user to enable and disable two different map layers. The interface uses setLayoutProperty to toggle the value for each layer's visibility property between visible and none. Mapbox GL requires WebGL support. Please check that you are using a supported browser and that WebGL is enabled.

How do I add a new style layer to a map?

Adds a new style layer to the map. On a Mapbox GL map, layers are used in styles for adding styling rules to specific subsets of data. A layer will contain a reference to the data for which they are defining a style. Use the before attribute to insert a layer before an existing layer.


1 Answers

You can use the Map#getStyle method to get a serialized representation of the entire style including the layers.

map.getStyle().layers 
like image 73
Lucas Wojciechowski Avatar answered Nov 10 '22 02:11

Lucas Wojciechowski