【问题标题】:Change text color in mapbox cluster map更改 mapbox 集群地图中的文本颜色
【发布时间】:2017-11-29 21:11:23
【问题描述】:

我正在尝试更改 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
    }
});

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

【问题讨论】:

    标签: javascript mapbox mapbox-gl


    【解决方案1】:

    要更改地图图层中的文本颜色,您需要"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"
      }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-28
      • 2023-03-21
      • 2020-11-01
      • 1970-01-01
      • 2021-11-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多