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


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:


The following screenshot is taken from there:

enter image description here

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

Your Answer

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

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