clusterProperties in mapbox-gl

Viewed 287

I want to draw clusters on my map but not with number of points inside the text-field

map.addLayer({
        id: 'cluster-count',
        type: 'symbol',
        source: 'stations',
        filter: ['has', 'point_count'],
        layout: {
            'text-field': '{point_count}',
            //'text-field': ['number-format', ['get', {point_count}]],
            'text-font': ['DIN Offc Pro Medium', 'Arial Unicode MS Bold'],
            'text-size': 12
        }
    });

but with %.

Something like that: {point_count / overall_number_of_points}

But I can't find any example of that thing.

1 Answers

I think you are looking for a Math expression for Mapbox:

["/", number, number]: number
["%", number, number]: number

In your case it could be something like this..

["%", ['get', 'point_count'], ['get', 'overall_number_of_points']]
Related