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.
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.
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.
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.
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.
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.
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.
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.
You can use the Map#getStyle
method to get a serialized representation of the entire style including the layers.
map.getStyle().layers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With