通过自定义点数据计算的聚类圆中的Mapbox GL自定义文本

时间:2018-07-23 03:03:21

标签: text cluster-computing customization mapbox-gl-js

我正在遵循群集的标准示例,但是我想知道是否可以替换放置在群集圆中的标准'point_count'文本。

在我的GEOJson数据中,对于每个等于1或0的位置/点,我都有一个名为“ PositiveNegative”的属性。例如: {"type":"Feature","properties":{"ID":151,"PositiveNegative":1},"geometry":{"type":"Point","coordinates":[-43.5663102,172.5922134]}}

我想算出每个群集中的正负总位置,并在每个群集中放置一些自定义文本。例如:“ 23积极/ 18消极”:请参阅我的快速模型:

enter image description here

到目前为止,这是我的代码:

map.addLayer({ id: "clusters", type: "circle", source: "posNegPoints", filter: ["has", "point_count"], paint: { "circle-color": [ "step", ["get", "point_count"], "#51bbd6", 100, "#f1f075", 750, "#f28cb1" ], "circle-radius": [ "step", ["get", "point_count"], 20, 100, 30, 750, 40 ] } });

map.addLayer({ id: "cluster-count", type: "symbol", source: "posNegPoints", filter: ["has", "point_count"], layout: { "text-field": "{point_count_abbreviated}", "text-font": ["DIN Offc Pro Medium", "Arial Unicode MS Bold"], "text-size": 12 } });

0 个答案:

没有答案