Skip to content

Instantly share code, notes, and snippets.

@Nickztar
Created March 20, 2021 15:31
Show Gist options
  • Select an option

  • Save Nickztar/024b7bc176d0d9967a761b242f724e4c to your computer and use it in GitHub Desktop.

Select an option

Save Nickztar/024b7bc176d0d9967a761b242f724e4c to your computer and use it in GitHub Desktop.
MarkerClusterOptions
export interface MarkerClustererOptions {
/**
* The grid size of a cluster in pixels. The grid is a square.
*
* @default `60`
*/
gridSize?: number;
/**
* The maximum zoom level at which clustering is enabled or
* `null` if clustering is to be enabled at all zoom levels.
*
* @default `null`
*/
maxZoom?: number;
/**
* Whether to zoom the map when a cluster marker is
* clicked. You may want to set this to `false` if you have installed a handler
* for the `click` event and it deals with zooming on its own.
*
* @default `true`
*/
zoomOnClick?: boolean;
/***
* Whether the position of a cluster marker should be
* the average position of all markers in the cluster. If set to `false`, the
* cluster marker is positioned at the location of the first marker added to the cluster.
*
* @default `false`
*/
averageCenter?: boolean;
/**
* The minimum number of markers needed in a cluster
* before the markers are hidden and a cluster marker appears.
*
* @default `2`
*/
minimumClusterSize?: number;
/**
* the z-index of a cluster.
*
* @default `google.maps.Marker.MAX_ZINDEX + 1`
*/
zIndex?: number;
/**
* Whether to ignore hidden markers in clusters. You
* may want to set this to `true` to ensure that hidden markers are not included
* in the marker count that appears on a cluster marker (this count is the value of the
* `text` property of the result returned by the default {@link calculator}).
* If set to `true` and you change the visibility of a marker being clustered, be
* sure to also call {@link MarkerClusterer#repaint()}.
*
* @default `false`
*/
ignoreHidden?: boolean;
/**
* The tooltip to display when the mouse moves over a cluster
* marker. (Alternatively, you can use a custom `calculator` function to specify a
* different tooltip for each cluster marker.)
*
* @default `""`
*/
title?: string;
/**
* The function used to determine
* the text to be displayed on a cluster marker and the index indicating which style to use
* for the cluster marker. The input parameters for the function are (1) the array of markers
* represented by a cluster marker and (2) the number of cluster icon styles. It returns a
* {@link ClusterIconInfo} object. The default `calculator` returns a
* `text` property which is the number of markers in the cluster and an
* `index` property which is one higher than the lowest integer such that
* `10^i` exceeds the number of markers in the cluster, or the size of the styles
* array, whichever is less. The `styles` array element used has an index of
* `index` minus 1. For example, the default `calculator` returns a
* `text` value of `"125"` and an `index` of `3`
* for a cluster icon representing 125 markers so the element used in the `styles`
* array is `2`. A `calculator` may also return a `title`
* property that contains the text of the tooltip to be used for the cluster marker. If
* `title` is not defined, the tooltip is set to the value of the `title`
* property for the MarkerClusterer.
*
* @default {@link MarkerClusterer.CALCULATOR}
*/
calculator?: Calculator;
/**
* The name of the CSS class defining general styles
* for the cluster markers. Use this class to define CSS styles that are not set up by the code
* that processes the `styles` array.
*
* @default `"cluster"`
*/
clusterClass?: string;
/**
* An array of {@link ClusterIconStyle} elements defining the styles
* of the cluster markers to be used. The element to be used to style a given cluster marker
* is determined by the function defined by the `calculator` property.
* The default is an array of {@link ClusterIconStyle} elements whose properties are derived
* from the values for `imagePath`, `imageExtension`, and `imageSizes`.
*
* @default `styles`
*/
styles?: ClusterIconStyle[];
/**
* Whether to allow the use of cluster icons that
* have sizes that are some multiple (typically double) of their actual display size. Icons such
* as these look better when viewed on high-resolution monitors such as Apple's Retina displays.
* Note: if this property is `true`, sprites cannot be used as cluster icons.
*
* @default `false`
*/
enableRetinaIcons?: boolean;
/**
* Set this property to the number of markers to be processed in a single batch when using
* a browser other than Internet Explorer (for Internet Explorer, use the batchSizeIE property instead).
*
* @default `MarkerClusterer.BATCH_SIZE`
*/
batchSize?: number;
/**
* When Internet Explorer is
* being used, markers are processed in several batches with a small delay inserted between
* each batch in an attempt to avoid Javascript timeout errors. Set this property to the
* number of markers to be processed in a single batch; select as high a number as you can
* without causing a timeout error in the browser. This number might need to be as low as 100
* if 15,000 markers are being managed, for example.
*
* @default `MarkerClusterer.BATCH_SIZE_IE`
*/
batchSizeIE?: number;
/**
* The full URL of the root name of the group of image files to use for cluster icons.
* The complete file name is of the form `imagePath`n.`imageExtension`
* where n is the image file number (1, 2, etc.).
*
* @default `MarkerClusterer.IMAGE_PATH`
*/
imagePath?: string;
/**
* The extension name for the cluster icon image files (e.g., `"png"` or
* `"jpg"`).
*
* @default `MarkerClusterer.IMAGE_EXTENSION`
*/
imageExtension?: string;
/**
* An array of numbers containing the widths of the group of
* `imagePath`n.`imageExtension` image files.
* (The images are assumed to be square.)
*
* @default `MarkerClusterer.IMAGE_SIZES`
*/
imageSizes?: number[];
/**
* A function to take the text attribute associated with the cluster and output a string to attach an
* ariaLabel to the cluster
*/
ariaLabelFn?: AriaLabelFn;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment