I'm struggling to find the right information in order to create a choropleth map using mapbox. Their examples are very vague.
I currently have a geojson showing the polygons for all the UK counties. I used map.addLayer to add this to the map, but at the moment, the whole map is the same color:
map.addLayer({
"id": 'counties',
"type": "fill",
"source": {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": counties
}
},
"layout": {},
"paint": {
"fill-color": fill,
"fill-opacity": 0.8
}
});
counties is the geojson file, which also includes a property called 'County'. In addition, I have returned an object, which returns key, value pairs of counties, and the number of times it appeared in my data, respectively:
{
"Bristol": 2,
"Cheshire": 1,
"City and County of the City of London": 14,
"City of Aberdeen": 1,
"City of Edinburgh": 3
}
How can I create a choropleth map using the data from my object, to return as different shades/color for the layer (e.g, counties such as Cheshire would be a lighter color, because the value is one, but City and County of the City of London would have a darker color because the value is 14?