1

I am trying to determine method of stying across a data range using 'get' expression and multiple criteria in Mapbox Studio using Mapbox Expressions. In the example below I want to style a marker matching symbol = 'Restaurant' AND title = 'Social Brewery and Kitchen'. Is this possible?

[
  "match",
  ["get", "title", 'Social Kitchen and Brewery'],
  ["get", "marker-symbol", 'Restaurant'],
  "#f9a951",
  "#000000" //fallback
]

1 Answer 1

2
+50

Try concatenating the values:

["match",
  ["concat",
    ["get", "title"],
    ["get", "marker-symbol"],
  ],
  "Social Kitchen and BreweryRestaurant",
  "#f9a951",
  "#000000" //fallback
]

You may want to add a separaror with a second nested concat (or maybe expect a space character between values in the first place, I haven't tested).

3
  • Would have thought there would be a more conventional way but this works for me. Thanks! Commented Jul 19, 2021 at 20:51
  • 1
    @wtgeographer it may seem this is an obvious feature. However, don't forget this is a client mapping framework; while there is nothing stopping it from offering more sophisticated relational data access (and Mapbox GL is already bursting with [more or less needed] functionality), I would not say that it should necessarily be used that way. Rather, IMO, pre-categorize and encode as much information as possible on the backend (and in DB), and transfer only the bare minimum of data to the client - think perfomance/bandwith, and security (i.e. obfuscating internal data structures).
    – geozelot
    Commented Jul 20, 2021 at 8:19
  • Agreed! Thanks @geozelot Commented Jul 21, 2021 at 19:42

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.