Guest User

Code

a guest
Feb 28th, 2017
753
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var layers = [
  2.     [150, '#f28cb1'],
  3.     [20, '#f1f075'],
  4.     [0, '#51bbd6']
  5. ];
  6. layers.forEach(function(layer, i) {
  7.     map.addLayer({
  8.         "id": "cluster-" + i,
  9.         "source": "markers",
  10.         "type": "circle",
  11.         "paint": {
  12.             "circle-color": layer[1],
  13.             "circle-radius": 10
  14.         },
  15.         "filter": i === 0 ? [">=", "point_count", layer[0]] : ["all", [">=", "point_count", layer[0]],
  16.             ["<", "point_count", layers[i - 1][0]]
  17.         ]
  18.     });
  19. });
  20. map.addLayer({
  21.     "id": "cluster-count",
  22.     "type": "symbol",
  23.     "source": "markers",
  24.     "layout": {
  25.         "text-field": "{point_count}",
  26.         "text-font": [
  27.             "Arial Unicode MS Bold"
  28.         ],
  29.         "text-size": 12,
  30.  
  31.         "icon-image": "{marker-symbol}",
  32.         "icon-size": 0.20
  33.     },
  34.     "paint": {
  35.         "text-color": "white"
  36.     }
  37. });
Add Comment
Please, Sign In to add comment