Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change text color in mapbox cluster map

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.

like image 755
Felix Avatar asked Jun 26 '17 22:06

Felix


1 Answers

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"
  }
});
like image 96
Denis Tsoi Avatar answered Sep 20 '22 09:09

Denis Tsoi