1

I have a geojson with several polygons. Each polygon has a name. I want to display all polygons except for the "boundingBox". I use the filter in addLayer():

"filter": ["all",["==", "$type", "Polygon"],["!=",["string", ['get', 'name'],""], "boundingBox"]]

but no polygons show up.

If I do:

"filter": ["==", "$type", "Polygon"]

all polygons show up.

What is going wrong here?

j3App
  • 1,510
  • 1
  • 17
  • 26
  • `all` -> It will show the polygon when all of the filters evaluates to `true`. It mean your one of the filter is evaluating to false. - https://docs.mapbox.com/mapbox-gl-js/style-spec/. – random Jul 01 '19 at 10:30

1 Answers1

3

Looks like you have a mix of deprecated filter syntax ($type) and expression syntax, which is not allowed.

Expression syntax and the deprecated syntax below cannot be mixed in a single filter definition. https://docs.mapbox.com/mapbox-gl-js/style-spec/#other-filter

Try

"filter": ["all",["==", ["geometry-type"], "Polygon"],["!=",["string", ['get', 'name'],""], "boundingBox"]]
jeffd
  • 61
  • 4