Currently in the process of creating an interactive choropleth map with different coloured regions to indicate rainfall levels. The problem I have is that to do this in mapbox GL JS, you have to create different layers to indicate the different colour fills.
Is it possible to use nested functions? For example, filtering in the fill-color option to allow me to keep it as one logical layer.
Something like this:
map.addLayer({
"id": "state-fills",
"type": "fill",
"source": "states",
"interactive": true,
"layout": {},
"paint": {
"fill-color": 'filter': [["==", "state", "stateproperty", 'color'],
["==", "state", "stateproperty", 'nextColor']],
"fill-opacity": 0.5
}
});