MarkerClusterer for Google Maps v3

The library creates and manages per-zoom-level clusters for large amounts of markers.

For a description and examples of how to use this library, check out the how-to.

class MarkerClusterer

This class extends google.maps.OverlayView.

Constructor

Constructor Description
MarkerClusterer(map:google.maps.Map, opt_markers:Array.<google.maps.Marker>, opt_options:Object) A Marker Clusterer that clusters markers.

Methods

Methods Return Value Description
addMarker(marker:google.maps.Marker, opt_nodraw:boolean) None Adds a marker to the clusterer and redraws if needed.
addMarkers(markers:Array.<google.maps.Marker>, opt_nodraw:boolean) None Add an array of markers to the clusterer.
clearMarkers() None Clears all clusters and markers from the clusterer.
getCalculator() function(Array|number) Get the calculator function.
getExtendedBounds(bounds:google.maps.LatLngBounds) google.maps.LatLngBounds Extends a bounds object by the grid size.
getGridSize() number Returns the size of the grid.
getMap() google.maps.Map Returns the google map that the clusterer is associated with.
getMarkers() Array. Returns the array of markers in the clusterer.
getMaxZoom() number Gets the max zoom for the clusterer.
getStyles() Object Gets the styles.
getTotalClusters() number Returns the number of clusters in the clusterer.
getTotalMarkers() Array. Returns the array of markers in the clusterer.
isZoomOnClick() boolean Whether zoom on click is set.
redraw() None Redraws the clusters.
removeMarker(marker:google.maps.Marker) boolean Remove a marker from the cluster.
resetViewport() None Clears all existing clusters and recreates them.
setCalculator(calculator:function(Array|number)) None Set the calculator function.
setGridSize(size:number) None Returns the size of the grid.
setMap(map:google.maps.Map) None Sets the google map that the clusterer is associated with.
setMaxZoom(maxZoom:number) None Sets the max zoom for the clusterer.
setStyles(styles:Object) None Sets the styles.