Change text color in mapbox cluster map
Asked Answered
E

1

16

I am trying to change the text color in the mapbox cluster map (https://www.mapbox.com/mapbox-gl-js/example/cluster/), but I can't figure out how.

Here is the relevant code piece:

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

Does anybody know how to do this? I would like to change the number labels to white.

Em answered 26/6, 2017 at 22:42 Comment(0)
N
56

To change the text color in a map layer you need the "paint" property to set the text-color property REF:

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

Example

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"
  }
});
Nicolella answered 28/6, 2017 at 9:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.