Class: MarkerClusterer

MarkerClusterer(map, opt_markersopt, opt_optionsopt)

new MarkerClusterer(map, opt_markersopt, opt_optionsopt)

Creates a MarkerClusterer object with the options specified in MarkerClustererOptions.
Parameters:
Name Type Attributes 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.
Source:

Extends

  • google.maps.OverlayView

Members

(static, constant) BATCH_SIZE :number

The number of markers to process in one batch.
Type:
  • number
Source:

(static, constant) BATCH_SIZE_IE :number

The number of markers to process in one batch (IE only).
Type:
  • number
Source:

(static, constant) IMAGE_EXTENSION :string

The default extension name for the marker cluster images.
Type:
  • string
Source:

(static, constant) IMAGE_PATH :string

The default root name for the marker cluster images.
Type:
  • string
Source:

(static, constant) IMAGE_SIZES :Array.<number>

The default array of sizes for the marker cluster images.
Type:
  • Array.<number>
Source:

Methods

addMarker(marker, opt_nodrawopt)

Adds a marker to the clusterer. The clusters are redrawn unless opt_nodraw is set to true.
Parameters:
Name Type Attributes Description
marker google.maps.Marker The marker to add.
opt_nodraw boolean <optional>
Set to true to prevent redrawing.
Source:

addMarkers(markers, opt_nodrawopt)

Adds an array of markers to the clusterer. The clusters are redrawn unless opt_nodraw is set to true.
Parameters:
Name Type Attributes Description
markers Array.<google.maps.Marker> The markers to add.
opt_nodraw boolean <optional>
Set to true to prevent redrawing.
Source:

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.
Source:

clearMarkers()

Removes all clusters and markers from the map and also removes all markers managed by the clusterer.
Source:

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.
Source:

distanceBetweenPoints_(p1, p2) → {number}

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.
Source:

getAverageCenter() → {boolean}

Returns the value of the averageCenter property.
Source:
Returns:
True if averageCenter property is set.
Type
boolean

getBatchSizeIE() → {number}

Returns the value of the batchSizeIE property.
Source:
Returns:
the value of the batchSizeIE property.
Type
number

getCalculator() → {function}

Returns the value of the calculator property.
Source:
Returns:
the value of the calculator property.
Type
function

getClusterClass() → {string}

Returns the value of the clusterClass property.
Source:
Returns:
the value of the clusterClass property.
Type
string

getClusters() → {Array}

Returns the current array of clusters formed by the clusterer.
Source:
Returns:
The array of clusters formed by the clusterer.
Type
Array

getEnableRetinaIcons() → {boolean}

Returns the value of the enableRetinaIcons property.
Source:
Returns:
True if enableRetinaIcons property is set.
Type
boolean

getGridSize() → {number}

Returns the value of the gridSize property.
Source:
Returns:
The grid size.
Type
number

getHideLabel() → {boolean}

Returns the value of the hideLabel property.
Source:
Returns:
the value of the hideLabel property.
Type
boolean

getIgnoreHidden() → {boolean}

Returns the value of the ignoreHidden property.
Source:
Returns:
True if ignoreHidden property is set.
Type
boolean

getImageExtension() → {string}

Returns the value of the imageExtension property.
Source:
Returns:
The value of the imageExtension property.
Type
string

getImagePath() → {string}

Returns the value of the imagePath property.
Source:
Returns:
The value of the imagePath property.
Type
string

getImageSizes() → {Array}

Returns the value of the imageSizes property.
Source:
Returns:
The value of the imageSizes property.
Type
Array

getMarkers() → {Array}

Returns the array of markers managed by the clusterer.
Source:
Returns:
The array of markers managed by the clusterer.
Type
Array

getMaxZoom() → {number}

Returns the value of the maxZoom property.
Source:
Returns:
The maximum zoom level.
Type
number

getMinimumClusterSize() → {number}

Returns the value of the minimumClusterSize property.
Source:
Returns:
The minimum cluster size.
Type
number

getStyles() → {Array}

Returns the value of the styles property.
Source:
Returns:
The array of styles defining the cluster markers to be used.
Type
Array

getTitle() → {string}

Returns the value of the title property.
Source:
Returns:
The content of the title text.
Type
string

getTotalClusters() → {number}

Returns the number of clusters formed by the clusterer.
Source:
Returns:
The number of clusters formed by the clusterer.
Type
number

getTotalMarkers() → {number}

Returns the number of markers managed by the clusterer.
Source:
Returns:
The number of markers.
Type
number

getZoomOnClick() → {boolean}

Returns the value of the zoomOnClick property.
Source:
Returns:
True if zoomOnClick property is set.
Type
boolean

isMarkerInBounds_(marker, bounds) → {boolean}

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.
Source:
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.
Source:

redraw_()

Redraws all the clusters.
Source:

removeMarker(marker, opt_nodrawopt, opt_noMapRemoveopt) → {boolean}

Removes a marker from the cluster and map. The clusters are redrawn unless opt_nodraw is set to true. Returns true if the marker was removed from the clusterer.
Parameters:
Name Type Attributes Description
marker google.maps.Marker The marker to remove.
opt_nodraw boolean <optional>
Set to true to prevent redrawing.
opt_noMapRemove boolean <optional>
Set to true to prevent removal from map but still removing from cluster management
Source:
Returns:
True if the marker was removed from the clusterer.
Type
boolean

removeMarker_(marker, removeFromMap) → {boolean}

Removes a marker and returns true if removed, false if not.
Parameters:
Name Type Description
marker google.maps.Marker The marker to remove
removeFromMap boolean set to true to explicitly remove from map as well as cluster manangement
Source:
Returns:
Whether the marker was removed or not
Type
boolean

removeMarkers(markers, opt_nodrawopt, opt_noMapRemoveopt) → {boolean}

Removes an array of markers from the cluster and map. The clusters are redrawn unless opt_nodraw is set to true. Returns true if markers were removed from the clusterer.
Parameters:
Name Type Attributes Description
markers Array.<google.maps.Marker> The markers to remove.
opt_nodraw boolean <optional>
Set to true to prevent redrawing.
opt_noMapRemove boolean <optional>
Set to true to prevent removal from map but still removing from cluster management
Source:
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.
Source:

resetViewport_(opt_hideopt)

Removes all clusters from the map. The markers are also removed from the map if opt_hide is set to true.
Parameters:
Name Type Attributes Description
opt_hide boolean <optional>
Set to true to also remove the markers from the map.
Source:

setAverageCenter(averageCenter)

Sets the value of the averageCenter property.
Parameters:
Name Type Description
averageCenter boolean The value of the averageCenter property.
Source:

setBatchSizeIE(batchSizeIE)

Sets the value of the batchSizeIE property.
Parameters:
Name Type Description
batchSizeIE number The value of the batchSizeIE property.
Source:

setCalculator(calculator)

Sets the value of the calculator property.
Parameters:
Name Type Description
calculator function The value of the calculator property.
Source:

setClusterClass(clusterClass)

Sets the value of the clusterClass property.
Parameters:
Name Type Description
clusterClass string The value of the clusterClass property.
Source:

setEnableRetinaIcons(enableRetinaIcons)

Sets the value of the enableRetinaIcons property.
Parameters:
Name Type Description
enableRetinaIcons boolean The value of the enableRetinaIcons property.
Source:

setGridSize(gridSize)

Sets the value of the gridSize property.
Parameters:
Name Type Description
gridSize number The grid size.
Source:

setHideLabel(printable)

Sets the value of the hideLabel property.
Parameters:
Name Type Description
printable boolean The value of the hideLabel property.
Source:

setIgnoreHidden(ignoreHidden)

Sets the value of the ignoreHidden property.
Parameters:
Name Type Description
ignoreHidden boolean The value of the ignoreHidden property.
Source:

setImageExtension(imageExtension)

Sets the value of the imageExtension property.
Parameters:
Name Type Description
imageExtension string The value of the imageExtension property.
Source:

setImagePath(imagePath)

Sets the value of the imagePath property.
Parameters:
Name Type Description
imagePath string The value of the imagePath property.
Source:

setImageSizes(imageSizes)

Sets the value of the imageSizes property.
Parameters:
Name Type Description
imageSizes Array The value of the imageSizes property.
Source:

setMaxZoom(maxZoom)

Sets the value of the maxZoom property.
Parameters:
Name Type Description
maxZoom number The maximum zoom level.
Source:

setMinimumClusterSize(minimumClusterSize)

Sets the value of the minimumClusterSize property.
Parameters:
Name Type Description
minimumClusterSize number The minimum cluster size.
Source:

setStyles(styles)

Sets the value of the styles property.
Parameters:
Name Type Description
styles Array.<ClusterIconStyle> The array of styles to use.
Source:

setTitle(title)

Sets the value of the title property.
Parameters:
Name Type Description
title string The value of the title property.
Source:

setZoomOnClick(zoomOnClick)

Sets the value of the zoomOnClick property.
Parameters:
Name Type Description
zoomOnClick boolean The value of the zoomOnClick property.
Source:

setupStyles_()

Sets up the styles object.
Source: