I tried to use setFilter method in mapbox but this method is used to filter existing layer's features depending on specific property but not filtering all layers according to geometry In other words, I need to filter the layers depending on geometry type (Point, LineString, Polygons)
1 Answer
You could get all layers of a style with
var layers = map.getStyle().layers
and then filter depending on the layer type (e.g. symbol
, line
, fill
).
Here's an official example which shows how to find the id of the first symbol layer in a map style:
https://docs.mapbox.com/mapbox-gl-js/example/geojson-layer-in-stack/
The following screenshot is taken from there: