The default Grid algorithm historically used in Google Maps marker clustering.

The Grid algorithm does not implement caching and markers may flash as the viewport changes. Instead use SuperClusterAlgorithm.

Hierarchy

  • AbstractViewportAlgorithm
    • GridAlgorithm

Constructors

Properties

clusters: Cluster[] = []
gridSize: number
maxDistance: number
maxZoom: number
state: {
    zoom: number;
} = ...

Type declaration

  • zoom: number
viewportPadding: number = 60

Methods

  • Parameters

    • marker: Marker
    • map: Map
    • projection: MapCanvasProjection

    Returns void

  • Helper function to bypass clustering based upon some map state such as zoom, number of markers, etc.

     cluster({markers, map}: AlgorithmInput): Cluster[] {
    if (shouldBypassClustering(map)) {
    return this.noop({markers})
    }
    }

    Type Parameters

    Parameters

    • __namedParameters: T

    Returns Cluster[]

Generated using TypeDoc