作为附件,群集器在伦敦显示 417 标记。
我想按阈值自定义一点。例如
<= 20: Display real number
From 20 to 50: 20+
From 50 to 100: 50+
From 100 to 200: 100+
> 200: 200+
如何将阈值应用于群集器?
答案 0 :(得分:2)
我找到了一种更改群集器中显示号的绝妙方法。
通过更改计算器方法
markerCluster.setCalculator(new_cluster_calculator);
function new_cluster_calculator (markers, numStyles) {
var index = 0;
var title = "";
var count = markers.length;
var countStr = count.toString();
var dv = countStr;
while (dv !== 0) {
dv = parseInt(dv / 10, 10);
index++;
}
index = Math.min(index, numStyles);
if (count >= 200) {
count = '200+';
} else if (count >= 100) {
count = '100+';
} else if (count >= 50) {
count = '50+';
}
return {
text: count,
index: index,
title: title
};
};