2017-03-01 121 views

回答

1

解決了下面的代碼

var layers = [ 
    [150], 
    [20], 
    [0] 
]; 
layers.forEach(function(layer, i) { 
    map.addLayer({ 
     "id": "cluster-" + i, 
     "source": "markers", 
     "type": "symbol", 
     "layout": { 
      "text-field": "{point_count}", 
      "text-font": [ 
       "Arial Unicode MS Bold" 
      ], 
      "text-size": 13, 
      "text-anchor": "bottom", 
      "icon-image": "emptyMarker", 
      "icon-size": 0.25 
     }, 
     "paint": { 
      "text-color": "white" 
     }, 
     "filter": i === 0 ? [">=", "point_count", layer[0]] : ["all", [">=", "point_count", layer[0]], 
      ["<", "point_count", layers[i - 1][0]] 
     ] 
    }); 
}); 
map.addLayer({ 
    "id": "cluster-count", 
    "type": "symbol", 
    "source": "markers" 
}); 
0

我認爲解決的辦法是:
1.計算所有中心的束縛孩子們的標誌
,並將它們存儲爲集羣的標記
2.你必須控制縮放動作,
如果被大於15那麼你只顯示孩子們的標誌
否則,如果是較少比15那麼你只顯示集羣的標記

+0

謝謝:)建議 –