修改MarkerClusterer图标以获得最高分数,而不是标记数 [英] modifying MarkerClusterer icons for top score, rather than marker count

查看:266
本文介绍了修改MarkerClusterer图标以获得最高分数,而不是标记数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我目前在开发环境中启动并运行vanillaMarkerClusterer(aprox 3000标记)。

每个标记都有一个与它相关的分数,我想对其进行更改,以便分组标记代表它们包含的标记的最高分(而不仅仅是标记数量)。



我应该去哪里,以及如何让这种变化发生?



谢谢!

p>

解决方案

使用setCalculator()方法来定义如何完成计算。以下是使用原始功能的代码。调整它以你想要的方式进行计算。计算器函数在每个集群中调用一次,所以结果是您想要的集群文本以及它应该具有的样式索引。

  your_clusterer.setCalculator(function(markers,numStyles){
var index = 0;
var count = markers.length;
var dv = count;
while dv!== 0){
dv = parseInt(dv / 10,10);
index ++;
}

index = Math.min(index,numStyles );
return {
text:count,
index:index
};
});


I'm looking for some advice on where to start with this:

I currently have "vanilla" MarkerClusterer up and running in a dev environment (aprox 3000 markers).

Each marker has a score associated with it, and i want to change it so that the cluster markers represent the top score of the markers they contain (rather than representing just the number of markers).

Where should i go, and how would i go about making this change happen?

Thanks!

解决方案

use the setCalculator() method to define how you want the calculation to be done. Here's the code that uses the original function. Tweak it to do the calculation the way you want it. The calculator function is called once per cluster, so the result is the text you want in the cluster and the index of the style it should have.

your_clusterer.setCalculator(function(markers, numStyles) {
  var index = 0;
  var count = markers.length;
  var dv = count;
  while (dv !== 0) {
    dv = parseInt(dv / 10, 10);
    index++;
  }

  index = Math.min(index, numStyles);
  return {
    text: count,
    index: index
  };
});

这篇关于修改MarkerClusterer图标以获得最高分数,而不是标记数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆