markerclusterer: anchor offset for cluster icons

Dick picture Dick · Feb 1, 2011 · Viewed 8.3k times · Source

I'm trying to slightly offset cluster icons created by the Google Maps Markerclusterer (V3). Short of modifying the existing code, I can't find a way to do this. Does anybody have an idea?

The Styles object in which you can provide a custom image URL accepts an anchor property, but this is to offset the generated marker item count.

Thanks!

Answer

NXT picture NXT · Nov 23, 2012

The proper way to do it is to adjust the anchorIcon property like this:

var clusterStyles = [
{
    height: 64,
    width: 53,
    anchorIcon: [20, 140]
},
{
    height: 64,
    width: 53,
    anchorIcon: [20, 140]
},
{
    height: 64,
    width: 53,
    anchorIcon: [20, 140]
}
];

var mcOptions = {
    styles: clusterStyles
};

var markerCluster = new MarkerClusterer(map, markers, mcOptions);