首页 > 解决方案 > mapbox-gl 中的集群属性

问题描述

我想在我的地图上绘制集群,但不是文本字段内的点数

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
        }
    });

但与%。

像这样的东西: {point_count / overall_number_of_points}

但我找不到那件事的任何例子。

标签: javascriptmapbox

解决方案


我认为您正在寻找Mapbox的数学表达式:

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

在你的情况下,它可能是这样的..

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

推荐阅读