Monday 22 January 2018

Matching multiple properties in mapbox gl js filter


I am trying to write a filter that will match on values from several properties of a layer.


For example, in my hypothetical layer of breweries, I'd like to match those breweries that have a state name of Utah, Texas or Florida and a brewery type of Irish or American.


I can filter on state like this



var stateFilter = ['match', ['get', 'stateNam'], ['Utah','Texas','Florida'], true, false]
map.setFilter('breweriesLayer',stateFilter)

Or on brewery type like this


var typeFilter = ['match', ['get', 'breweryType'], ['Irish','American'], true, false]
map.setFilter('breweriesLayer',typeFilter)

How can I combine the two examples above into one filter? I looked at using expressions and concatenation of fields but in my actual use case, I have several fields with 100s of possible values, making the expressions cumbersome.




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...