Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Data driven styling using multiple filters in mapbox gl js

Common approach of data-driven style using filters is:

"filter": ["==", "Label Type", "CurbRamp"] // Using one data value/property

How do I incorporate multiple filters; so incorporating an 'AND' condition using multiple data properties, something like:

        // "filter": {
        //     ["==", "Severity", "2.0"],
        //     ["==", "Label Type", "Problem"]
        // }

I haven't been able to find any examples on the internet.

like image 462
Geekster Avatar asked Jun 05 '26 23:06

Geekster


1 Answers

You can use an all expression:

["all", <filter-0>, <filter-1>, <filter-n>]

There's also any and none for combining filters.

Check the documentation here: https://docs.mapbox.com/mapbox-gl-js/style-spec/expressions/#all

like image 50
Scarysize Avatar answered Jun 07 '26 13:06

Scarysize



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!