我正在尝试更改地图集群集地图中的文字颜色(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
}
});
有人知道怎么做吗?我想将数字标签更改为白色。
答案 0 :(得分:9)
要更改地图图层中的文字颜色,您需要使用"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"
}
});