new MarkerClusterer(map [, opt_markers] [, opt_options])
Creates a MarkerClusterer object with the options specified in MarkerClustererOptions.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
map |
google.maps.Map | The Google map to attach to. |
|
opt_markers |
Array.<google.maps.Marker> |
<optional> |
The markers to be added to the cluster. |
opt_options |
MarkerClustererOptions |
<optional> |
The optional parameters. |
Extends
- google.maps.OverlayView
Members
-
<static, constant> BATCH_SIZE :number
-
The number of markers to process in one batch.
Type:
- number
-
<static, constant> BATCH_SIZE_IE :number
-
The number of markers to process in one batch (IE only).
Type:
- number
-
<static, constant> IMAGE_EXTENSION :string
-
The default extension name for the marker cluster images.
Type:
- string
-
<static, constant> IMAGE_PATH :string
-
The default root name for the marker cluster images.
Type:
- string
-
<static, constant> IMAGE_SIZES :Array.<number>
-
The default array of sizes for the marker cluster images.
Type:
- Array.<number>
Methods
-
addMarker(marker [, opt_nodraw])
-
Adds a marker to the clusterer. The clusters are redrawn unless
opt_nodraw
is set totrue
.Parameters:
Name Type Argument Description marker
google.maps.Marker The marker to add.
opt_nodraw
boolean <optional>
Set to
true
to prevent redrawing. -
addMarkers(markers [, opt_nodraw])
-
Adds an array of markers to the clusterer. The clusters are redrawn unless
opt_nodraw
is set totrue
.Parameters:
Name Type Argument Description markers
Array.<google.maps.Marker> The markers to add.
opt_nodraw
boolean <optional>
Set to
true
to prevent redrawing. -
addToClosestCluster_(marker)
-
Adds a marker to a cluster, or creates a new cluster.
Parameters:
Name Type Description marker
google.maps.Marker The marker to add.
-
clearMarkers()
-
Removes all clusters and markers from the map and also removes all markers
managed by the clusterer. -
createClusters_(iFirst)
-
Creates the clusters. This is done in batches to avoid timeout errors
in some browsers when there is a huge number of markers.Parameters:
Name Type Description iFirst
number The index of the first marker in the batch of
markers to be added to clusters. -
distanceBetweenPoints_(p1, p2)
-
Calculates the distance between two latlng locations in km.
Parameters:
Name Type Description p1
google.maps.LatLng The first lat lng point.
p2
google.maps.LatLng The second lat lng point.
- Source:
- See:
Returns:
The distance between the two points in km.
- Type
- number
-
fitMapToMarkers()
-
Fits the map to the bounds of the markers managed by the clusterer.
-
getAverageCenter()
-
Returns the value of the
averageCenter
property.Returns:
True if averageCenter property is set.
- Type
- boolean
-
getBatchSizeIE()
-
Returns the value of the
batchSizeIE
property.Returns:
the value of the batchSizeIE property.
- Type
- number
-
getCalculator()
-
Returns the value of the
calculator
property.Returns:
the value of the calculator property.
- Type
- function
-
getClusterClass()
-
Returns the value of the
clusterClass
property.Returns:
the value of the clusterClass property.
- Type
- string
-
getClusters()
-
Returns the current array of clusters formed by the clusterer.
Returns:
The array of clusters formed by the clusterer.
- Type
- Array
-
getEnableRetinaIcons()
-
Returns the value of the
enableRetinaIcons
property.Returns:
True if enableRetinaIcons property is set.
- Type
- boolean
-
getGridSize()
-
Returns the value of the
gridSize
property.Returns:
The grid size.
- Type
- number
-
getIgnoreHidden()
-
Returns the value of the
ignoreHidden
property.Returns:
True if ignoreHidden property is set.
- Type
- boolean
-
getImageExtension()
-
Returns the value of the
imageExtension
property.Returns:
The value of the imageExtension property.
- Type
- string
-
getImagePath()
-
Returns the value of the
imagePath
property.Returns:
The value of the imagePath property.
- Type
- string
-
getImageSizes()
-
Returns the value of the
imageSizes
property.Returns:
The value of the imageSizes property.
- Type
- Array
-
getMarkers()
-
Returns the array of markers managed by the clusterer.
Returns:
The array of markers managed by the clusterer.
- Type
- Array
-
getMaxZoom()
-
Returns the value of the
maxZoom
property.Returns:
The maximum zoom level.
- Type
- number
-
getMinimumClusterSize()
-
Returns the value of the
minimumClusterSize
property.Returns:
The minimum cluster size.
- Type
- number
-
getStyles()
-
Returns the value of the
styles
property.Returns:
The array of styles defining the cluster markers to be used.
- Type
- Array
-
getTitle()
-
Returns the value of the
title
property.Returns:
The content of the title text.
- Type
- string
-
getTotalClusters()
-
Returns the number of clusters formed by the clusterer.
Returns:
The number of clusters formed by the clusterer.
- Type
- number
-
getTotalMarkers()
-
Returns the number of markers managed by the clusterer.
Returns:
The number of markers.
- Type
- number
-
getZoomOnClick()
-
Returns the value of the
zoomOnClick
property.Returns:
True if zoomOnClick property is set.
- Type
- boolean
-
isMarkerInBounds_(marker, bounds)
-
Determines if a marker is contained in a bounds.
Parameters:
Name Type Description marker
google.maps.Marker The marker to check.
bounds
google.maps.LatLngBounds The bounds to check against.
Returns:
True if the marker is in the bounds.
- Type
- boolean
-
pushMarkerTo_(marker)
-
Pushes a marker to the clusterer.
Parameters:
Name Type Description marker
google.maps.Marker The marker to add.
-
redraw_()
-
Redraws all the clusters.
-
removeMarker(marker [, opt_nodraw])
-
Removes a marker from the cluster. The clusters are redrawn unless
opt_nodraw
is set totrue
. Returnstrue
if the
marker was removed from the clusterer.Parameters:
Name Type Argument Description marker
google.maps.Marker The marker to remove.
opt_nodraw
boolean <optional>
Set to
true
to prevent redrawing.Returns:
True if the marker was removed from the clusterer.
- Type
- boolean
-
removeMarker_(marker)
-
Removes a marker and returns true if removed, false if not.
Parameters:
Name Type Description marker
google.maps.Marker The marker to remove
Returns:
Whether the marker was removed or not
- Type
- boolean
-
removeMarkers(markers [, opt_nodraw])
-
Removes an array of markers from the cluster. The clusters are redrawn unless
opt_nodraw
is set totrue
. Returnstrue
if markers
were removed from the clusterer.Parameters:
Name Type Argument Description markers
Array.<google.maps.Marker> The markers to remove.
opt_nodraw
boolean <optional>
Set to
true
to prevent redrawing.Returns:
True if markers were removed from the clusterer.
- Type
- boolean
-
repaint()
-
Recalculates and redraws all the marker clusters from scratch.
Call this after changing any properties. -
resetViewport_( [opt_hide])
-
Removes all clusters from the map. The markers are also removed from the map
ifopt_hide
is set totrue
.Parameters:
Name Type Argument Description opt_hide
boolean <optional>
Set to
true
to also remove the markers
from the map. -
setAverageCenter(averageCenter)
-
Sets the value of the
averageCenter
property.Parameters:
Name Type Description averageCenter
boolean The value of the averageCenter property.
-
setBatchSizeIE(batchSizeIE)
-
Sets the value of the
batchSizeIE
property.Parameters:
Name Type Description batchSizeIE
number The value of the batchSizeIE property.
-
setCalculator(calculator)
-
Sets the value of the
calculator
property.Parameters:
Name Type Description calculator
function The value
of the calculator property. -
setClusterClass(clusterClass)
-
Sets the value of the
clusterClass
property.Parameters:
Name Type Description clusterClass
string The value of the clusterClass property.
-
setEnableRetinaIcons(enableRetinaIcons)
-
Sets the value of the
enableRetinaIcons
property.Parameters:
Name Type Description enableRetinaIcons
boolean The value of the enableRetinaIcons property.
-
setGridSize(gridSize)
-
Sets the value of the
gridSize
property.Parameters:
Name Type Description gridSize
number The grid size.
-
setIgnoreHidden(ignoreHidden)
-
Sets the value of the
ignoreHidden
property.Parameters:
Name Type Description ignoreHidden
boolean The value of the ignoreHidden property.
-
setImageExtension(imageExtension)
-
Sets the value of the
imageExtension
property.Parameters:
Name Type Description imageExtension
string The value of the imageExtension property.
-
setImagePath(imagePath)
-
Sets the value of the
imagePath
property.Parameters:
Name Type Description imagePath
string The value of the imagePath property.
-
setImageSizes(imageSizes)
-
Sets the value of the
imageSizes
property.Parameters:
Name Type Description imageSizes
Array The value of the imageSizes property.
-
setMaxZoom(maxZoom)
-
Sets the value of the
maxZoom
property.Parameters:
Name Type Description maxZoom
number The maximum zoom level.
-
setMinimumClusterSize(minimumClusterSize)
-
Sets the value of the
minimumClusterSize
property.Parameters:
Name Type Description minimumClusterSize
number The minimum cluster size.
-
setStyles(styles)
-
Sets the value of the
styles
property.Parameters:
Name Type Description styles
Array.<ClusterIconStyle> The array of styles to use.
-
setTitle(title)
-
Sets the value of the
title
property.Parameters:
Name Type Description title
string The value of the title property.
-
setupStyles_()
-
Sets up the styles object.
-
setZoomOnClick(zoomOnClick)
-
Sets the value of the
zoomOnClick
property.Parameters:
Name Type Description zoomOnClick
boolean The value of the zoomOnClick property.
Events
-
click
-
This event is fired when a cluster marker is clicked.
Parameters:
Name Type Description c
Cluster The cluster that was clicked.
-
clusteringbegin
-
This event is fired when the
MarkerClusterer
begins
clustering markers.Parameters:
Name Type Description mc
MarkerClusterer The MarkerClusterer whose markers are being clustered.
-
clusteringend
-
This event is fired when the
MarkerClusterer
stops
clustering markers.Parameters:
Name Type Description mc
MarkerClusterer The MarkerClusterer whose markers are being clustered.
-
mouseout
-
This event is fired when the mouse moves out of a cluster marker.
Parameters:
Name Type Description c
Cluster The cluster that the mouse moved out of.
-
mouseover
-
This event is fired when the mouse moves over a cluster marker.
Parameters:
Name Type Description c
Cluster The cluster that the mouse moved over.