so I’ve been tasked with dynamically styling lots of data to be displayed on our app. The data has currently been split into multiple tables and styled individually before being displayed. I am looking to condense the amount of tables used to save time in the long run. An example of this is we have data for rounds 1,2,3,4 and the result of the putt either HOLED or MISSED. Instead of splitting this into 8 tables I am trying to use one table to style for instance round 1 and holed, round 1 and missed etc..
I have tried a number of ways to do this, with cases, matches and filters. Here is an example
"id": "app_shotdata_22_putts",
"source": "clere",
"source-layer": "app_shotdata_22_putts",
"type": "circle",
"layout": {
"visibility": "none"
},
"paint": {
"circle-radius": 3,
"circle-color": [
"case",
[
"all",
["==", ["get", "round"], "r1"],
["==", ["get", "putt_res"], "HOLED"]
],
"rgba(0,100,0,0.5)",
[
"all",
["==", ["get", "round"], "r1"],
["==", ["get", "putt_res"], "MISSED"]
],
"rgba(255,255,255,0.5)",
"rgba(255,255,255,0.5)"
],
"circle-stroke-width": 2,
"circle-stroke-color": "rgba(255,255,255,0.5)"
},
"minzoom": 12,
"maxzoom": 0,
"metadata": {
"displayName": "Putts",
"children": [],
"isTree": true,
"isVisible": false
}
}
I am expecting that when the layer is toggled on the app it will display green for putts holed in round 1 and red for putts missed in round 1. Eventually I would like to build this up to be able to toggle by round and then show all the holed/missed putts within that specific round.
I am able to get this all working for using just one property to style by but I’m falling down on using multiple.
No matter which way I do it though I end up with an error RNMapbox: Invalid color value: using red
at CircleLayer, I have had this error in the past and it was due to no default color being set but I have set the default here, I don’t think the error codes are particularly informative. Any advice on how to get this working would be appreciated.
Thanks!
user25311206 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.