2

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 1

1

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:

enter image description here

1
  • Thanks @pathmapper so much Nov 10, 2020 at 12:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.