Question

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.

Was it helpful?

Solution

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 :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top