KBlack
KBlack

Reputation: 45

google maps MarkerCluster for api v3

I use markerclusterer and it works fine so far.

It looks like the markerclusterer combines 1 to 10 markers with the blue cluster icon, 11 to 100 with the yellow icon and over 100 with the red icon.

How can i change this? Is there a way with an option setting to change this range values? Let's say 1-5 blue icon, 5-50 yellow icon, over 50 red icon.

Upvotes: 2

Views: 1563

Answers (1)

aniri
aniri

Reputation: 1831

Check out this function from the file markerclusterer.js

    MarkerClusterer.prototype.calculator_ = 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
  };
};

This is the method that returns the marker iamge to be used depending on the number of markers. You will have to replace the current logic with the one you want to use :)

Upvotes: 1

Related Questions