MarkerClusterer Calculator Example

1,537 views
Skip to first unread message

orhanc

unread,
Apr 30, 2012, 7:21:43 AM4/30/12
to google-maps-utility-library-v3
I'm trying to make average speed of the markers. Each markers title is
the speed. Here is my function but the label on the group won't
change. What am i doing wrong?

var markerCluster = new MarkerClusterer(map, markers, mcOptions,
{ 'calculator': averageSpeed(markers) });

function averageSpeed(markers) {
var total = 0, counted = 0;
for (var i = 0; i < markers.length; i++) {
if (markers[i].title > 0) { // if markers speed is 0 skip
total += parseInt(markers[i].title);
counted++;
}
}
var value = Math.round(total * 10 / markers.length) / 10;
var index = parseInt(value / 30, 10) + 1;
return {
text: total / counted,
index: index
};
}
Reply all
Reply to author
Forward
0 new messages