更改 mapbox 集群地图中的文本颜色

Change text color in mapbox cluster map

我正在尝试更改 mapbox 集群图中的文本颜色 (https://www.mapbox.com/mapbox-gl-js/example/cluster/),但我不知道如何更改。

相关代码如下:

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

有人知道怎么做吗?我想将数字标签更改为白色。

要更改地图图层中的文本颜色,您需要 "paint" 属性 来设置 text-color 属性 REF:

paint: {
  "text-color": "#ffffff"
}

例子

map.addLayer({
  id: "cluster-count",
  type: "symbol",
  source: "grundbuch",
  filter: ["has", "point_count"],
  layout: {
    "text-field": "{point_count_abbreviated}",
    "text-font": ["DIN Offc Pro Medium", "Arial Unicode MS Bold"],
    "text-size": 12
  },
  paint: {
    "text-color": "#ffffff"
  }
});