import * as L from 'leaflet'; import type { FitBoundsOptions, Icon, LatLng, LatLngBounds, LatLngExpression, Layer, Marker, Path, Point, PointExpression } from 'leaflet'; import type { MarkerClusterGroup } from './MarkerClusterGroup.js'; export type ClusterChild = M & { getLatLng(): LatLng; setLatLng(latlng: LatLngExpression): unknown; isPopupOpen(): boolean; openPopup(): unknown; closePopup(): unknown; clusterHide?(): unknown; clusterShow?(): unknown; setZIndexOffset?(offset: number): unknown; }; export type SpiderfyShape = { _2PI: number; /** * Related to the circumference of the circle. */ _circleFootSeparation: number; _circleStartAngle: number; /** * Related to the size of the spiral. */ _spiralFootSeparation: number; _spiralLengthStart: number; _spiralLengthFactor: number; /** * Marker count from which a spiral is shown instead of a circle. */ _circleSpiralSwitchover: number; }; /** * The cluster each marker is in, the group's top level one if no other. Clusters keep theirs in `_parent`. Shared * between groups since a marker can be in one group only, and refreshIconOptions only has the marker to go by. * @type {WeakMap>} */ export declare const parents: WeakMap>; /** * Whether the layer has an element to animate: a marker, or a path with the SVG renderer. * @param {Layer} layer * @returns {layer is Marker | Path} */ export declare function canAnimate(layer: Layer): layer is Marker | Path; /** * The opacity to fade the layer out from. A path's options.opacity is its stroke's, and it's hidden with the element's. * @param {Marker | Path} layer */ export declare function animationOpacity(layer: Marker | Path): number; /** * Animates a marker into its current state from the given one. Leaflet keeps positioning the icon and shadow with an * inline `transform`; the animation moves them with the separate `translate` property on top of it, so the marker can * stay at its real latlng. The final opacity is the inline one, so the caller sets it (e.g. clusterHide) before. * @param {Marker | Path} marker * @param {Point | null} from Pixel offset to start from, or null to start at the marker's position. * @param {Point | null} to Pixel offset to end at, or null. It's not held, so the marker should end up hidden or removed. * @param {number | undefined} fromOpacity Opacity to fade from. * @param {number} duration * @param {boolean} [withZoom] Move with the timing of the map zoom animation that's starting. */ export declare function animateMarker(marker: Marker | Path, from: Point | null, to: Point | null, fromOpacity: number | undefined, duration: number, withZoom?: boolean): void; /** * Cancels our running animations on the elements (and their descendants with subtree), putting them in their final * state right away. * @param {Element[]} elements * @param {boolean} [subtree] */ export declare function cancelAnimations(elements: Element[], subtree?: boolean): void; /** * Cancels the marker's running animations, putting it where it is and at its inline opacity right away. * @param {Layer} layer */ export declare function stopAnimations(layer: Layer): void; /** * A cluster of markers in a `MarkerClusterGroup`, shown as a marker whose icon comes from the group's * `iconCreateFunction`. Clusters are created by the group, and are the `layer` of its `cluster*` events. * @template {Layer} [M=Marker] The group's member layers. */ export declare class MarkerCluster extends L.Marker { /** Its point in the group's distance grids, that of its first marker. @type {Point | undefined} */ _gridPoint: Point | undefined; _group: MarkerClusterGroup; _zoom: number; /** @type {ClusterChild[]} */ _markers: ClusterChild[]; /** @type {MarkerCluster[]} */ _childClusters: MarkerCluster[]; _childCount: number; _iconNeedsUpdate: boolean; _boundsNeedUpdate: boolean; /** Spiderfied and fading out in a live map zoom (see _fadeUnspiderfy). */ _fading: boolean; _bounds: LatLngBounds; /** @type {MarkerCluster | undefined} */ _parent: MarkerCluster | undefined; /** @type {Icon | undefined} */ _iconObj: Icon | undefined; /** @type {LatLng} */ _wLatLng: LatLng; /** * @param {MarkerClusterGroup} group * @param {number} zoom * @param {ClusterChild | MarkerCluster} [a] * @param {ClusterChild | MarkerCluster} [b] */ constructor(group: MarkerClusterGroup, zoom: number, a?: ClusterChild | MarkerCluster, b?: ClusterChild | MarkerCluster); /** * All markers in this cluster and its child clusters, appended to `storageArray` if given. * @param {M[] | null} [storageArray] * @param {boolean} [ignoreDraggedMarker] Leave out markers being dragged. * @returns {M[]} */ getAllChildMarkers(storageArray?: M[] | null, ignoreDraggedMarker?: boolean): M[]; /** * @param {ClusterChild[]} storageArray * @param {boolean} [ignoreDraggedMarker] * @returns {ClusterChild[]} */ _getChildren(storageArray?: ClusterChild[], ignoreDraggedMarker?: boolean): ClusterChild[]; /** The number of markers in this cluster and its child clusters. */ getChildCount(): number; /** * Zooms in to the lowest zoom that splits the cluster, or that shows all of its bounds. * @param {FitBoundsOptions} [fitBoundsOptions] */ zoomToBounds(fitBoundsOptions?: FitBoundsOptions): void; /** The bounds of all markers in the cluster. */ getBounds(): LatLngBounds; /** The convex hull of the cluster's markers, as shown on hover with `showCoverageOnHover`. */ getConvexHull(): LatLng[]; _updateIcon(): void; createIcon(): HTMLElement; createShadow(): HTMLImageElement | null; _getPopupAnchor(): PointExpression; /** @param {string} [direction] Taken by Leaflet 2.0.0-beta.4 and later. */ _getTooltipAnchor(direction?: string): PointExpression; /** * @template T * @param {() => T} fn */ _withIconObj(fn: () => T): T; _initIcon(): void; _removeIcon(): void; _showCoverage(): void; _hideCoverage(): void; /** * Updates aria-expanded, and when collapsing, moves focus to the cluster from a spiderfied marker that's about * to go. * @param {boolean} expanded */ _setExpanded(expanded: boolean): void; /** @param {ClusterChild | MarkerCluster} child */ _addChild(child: ClusterChild | MarkerCluster): void; _recalculateBounds(): void; _addToMap(): void; /** * Moves the markers and clusters below us into center and fades them out. * @param {LatLngBounds} bounds * @param {Point} center * @param {number} maxZoom */ _recursivelyAnimateChildrenIn(bounds: LatLngBounds, center: Point, maxZoom: number): void; /** * @param {LatLngBounds} bounds * @param {LatLngBounds} previousBounds * @param {number} mapMinZoom * @param {number} previousZoomLevel * @param {number} newZoomLevel */ _recursivelyAnimateChildrenInAndAddSelfToMap(bounds: LatLngBounds, previousBounds: LatLngBounds, mapMinZoom: number, previousZoomLevel: number, newZoomLevel: number): void; /** * Adds the markers and clusters below us down to zoomLevel to the map. With startPos, they move out of it and the * markers fade in. * @param {LatLng | null} startPos * @param {number} zoomLevel * @param {LatLngBounds} bounds */ _recursivelyAddChildrenToMap(startPos: LatLng | null, zoomLevel: number, bounds: LatLngBounds): void; /** * @param {LatLngBounds} previousBounds * @param {number} mapMinZoom * @param {number} zoomLevel * @param {LatLngBounds} [exceptBounds] If set, don't remove any markers/clusters in it. * @param {boolean} [keepPopups] Don't remove markers/clusters with an open popup. */ _recursivelyRemoveChildrenFromMap(previousBounds: LatLngBounds, mapMinZoom: number, zoomLevel: number, exceptBounds?: LatLngBounds, keepPopups?: boolean): void; /** * Runs the given functions recursively on this and child clusters. * @param {LatLngBounds} boundsToApplyTo The bounds of the clusters to recurse into. * @param {number} zoomLevelToStart Zoom level to start running functions at (inclusive). * @param {number} zoomLevelToStop Zoom level to stop running functions at (inclusive). * @param {((c: MarkerCluster) => void) | null} [runAtEveryLevel] Applied at every level. * @param {(c: MarkerCluster) => void} [runAtBottomLevel] Applied at only the bottom level. */ _recursively(boundsToApplyTo: LatLngBounds, zoomLevelToStart: number, zoomLevelToStop: number, runAtEveryLevel?: ((c: MarkerCluster) => void) | null, runAtBottomLevel?: (c: MarkerCluster) => void): void; _isSingleParent(): boolean; /** Spreads out the cluster's markers around it, with legs to its center. */ spiderfy(): void; /** Brings the markers of a spiderfied cluster back in. */ unspiderfy(): void; /** @param {boolean} [withZoom] Called when a map zoom animation starts. */ _unspiderfy(withZoom?: boolean): void; /** * @this {MarkerCluster & SpiderfyShape} * @param {number} count * @param {Point} centerPt */ _generatePointsCircle(this: MarkerCluster & SpiderfyShape, count: number, centerPt: Point): Point[]; /** * @this {MarkerCluster & SpiderfyShape} * @param {number} count * @param {Point} centerPt */ _generatePointsSpiral(this: MarkerCluster & SpiderfyShape, count: number, centerPt: Point): Point[]; /** * Fades the spider out in place for a live map zoom. It stays spiderfied, and Canvas paths stay visible, until * _noanimationUnspiderfy removes it; unspiderfying before that does so right away. */ _fadeUnspiderfy(): void; _noanimationUnspiderfy(): void; /** * @param {ClusterChild[]} childMarkers * @param {Point[]} positions */ _animationSpiderfy(childMarkers: ClusterChild[], positions: Point[]): void; /** * With withZoom, it runs right after a zoom animation starts, when the map is already at the new zoom: setLatLng puts * a marker at its new position, and it moves there from where it was with the zoom transition, so our animation * moves it on from there to the cluster, with the same timing to keep it on a straight line. * @param {boolean} withZoom */ _animationUnspiderfy(withZoom: boolean): void; } /** * Non-animated versions of everything, for groups with `animate: false`. * @template {Layer} [M=Marker] * @extends {MarkerCluster} */ export declare class MarkerClusterNonAnimated extends MarkerCluster { /** * @param {ClusterChild[]} childMarkers * @param {Point[]} positions */ _animationSpiderfy(childMarkers: ClusterChild[], positions: Point[]): void; _animationUnspiderfy(): void; _fadeUnspiderfy(): void; }