So i am currently clustering a grid of points on my map with help from the Mapbox example here: Create and style clusters
The example code from Mapbox counts the number of points and displays it like this - using the variable point_count_abbreviated
:
map.addLayer({
id: "cluster-count",
...
layout: {
"text-field": "{point_count_abbreviated}",
},
...
})
My geoJSON source looks something like this:
{
"type": "Feature",
"geometry": { ... },
"properties": {
"location": { ... },
"id": 111,
...
"value": {
"count": 2
}
}
}
What I am trying to do is to add together all the "properties.value.count", and display the sum on each cluster. I have tried the examples in the documentation about clusterProperties but since my count variable is nested inside the value object, I am having a hard time making it work.
So I guess something like this in the cluster source definition:
clusterProperties: {"sum": ["+", ["object", "value", ['get, 'count']]]}
And display it in the layer:
layout: {
"text-field": ['get', 'sum'],
},
Could someone please point me in the right direction? :)