The library creates and manages per-zoom-level clusters for large amounts of
markers.
This is a v3 implementation of the
v2 MarkerClusterer.
For a description and examples of how to use this library, check out the how-to.
This class extends google.maps.OverlayView
.
Constructor | Description |
---|---|
MarkerClusterer(map:google.maps.Map, opt_markers:Array.<google.maps.Marker>, opt_options:Object) |
A Marker Clusterer that clusters markers. |
Name | Type | Description |
---|---|---|
gridSize |
number |
The grid size of a cluster in pixels. |
maxZoom |
number |
The maximum zoom level that a marker can be part of a cluster. |
zoomOnClick |
boolean |
Whether the default behaviour of clicking on a cluster is to zoom into it. |
averageCenter |
boolean |
Whether the center of each cluster should be the average of all markers in the cluster. |
minimumClusterSize |
number |
The minimum number of markers to be in a cluster before the markers are hidden and a count is shown. |
styles |
object |
An object that has style properties. |
Name | Type | Description |
---|---|---|
url |
string |
The image url. |
height |
number |
The image height. |
width |
number |
The image width. |
anchor |
Array |
The anchor position of the label text. |
textColor |
string |
The text color. |
textSize |
number |
The text size. |
backgroundPosition |
string |
The position of the backgound x, y. |
iconAnchor |
Array |
The anchor position of the icon x, y. |
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 |
Adds an array of markers to the clusterer. |
clearMarkers() |
None |
Clears all clusters and markers from the clusterer. |
getCalculator() |
function(Array|number) |
Gets the calculator function. |
getExtendedBounds(bounds:google.maps.LatLngBounds) |
google.maps.LatLngBounds |
Extends a bounds object by the grid size. |
getGridSize() |
number |
Gets the size of the grid. |
getMap() |
google.maps.Map |
Gets the google map that the clusterer is associated with. |
getMarkers() |
Array. |
Gets the array of markers in the clusterer. |
getMaxZoom() |
number |
Gets the max zoom for the clusterer. |
getStyles() |
Object |
Gets the styles. |
getTotalClusters() |
number |
Gets the number of clusters in the clusterer. |
getTotalMarkers() |
Array. |
Gets 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 |
Removes a marker from the cluster. |
resetViewport() |
None |
Clears all existing clusters and recreates them. |
setCalculator(calculator:function(Array|number)) |
None |
Sets the calculator function. |
setGridSize(size:number) |
None |
Sets 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. |