I am working in a project on which i use MarkerClustererPlus for Google Maps V3. I've read the documentation but i can't find anywhere how to change the default value that a marker cluster displays(the number of pins in the cluster). I want to change that value with a sum of some values contained in the pins of that cluster. Can this be achieved?
You must set a custom calculator-function.
In this function iterate over all markers, sum what you want to and calculate the index of the style.
Example( will display a sum of a marker-property named prop
in the cluster-icon):
markerCluster.setCalculator(function(markers, numStyles) {
var val=0,//this will be the text you see in the cluster-icon
index=0,
dv;
for(var m=0;m<markers.length;++m){
//add the value of the markers prop-property to val
val+=Number(markers[m].prop);
}
dv = val;
while (dv !== 0) {
dv = parseInt(dv / 10, 10);
index++;
}
index = Math.min(index, numStyles);
return {
text: val,
index: index
};
}
);