UNPKG

@yandex/ymaps3-types

Version:

Types for ymaps3 maps library

126 lines (125 loc) 4.96 kB
import type { YMapEntity } from "../../.."; import type { LngLat } from "../../../common/types"; import type { ClustererObject, Feature, IClusterMethod } from "./interface"; /** * YMapClusterer props */ type YMapClustererProps = { /** Clusterisation method */ method: IClusterMethod; /** Features */ features: Feature[]; /** Function to create marker for point*/ marker: (feature: Feature) => YMapEntity<unknown>; /** Function to create marker for cluster*/ cluster: (coordinates: LngLat, features: Feature[]) => YMapEntity<unknown>; /** The amount of time that may be passed before the render method can be called again */ tickTimeout?: number; /** Return false, if you want to override the render */ onRender?: (clusters: ClustererObject[]) => void | false; /** * Maximum zoom for clusterisation. * If map zoom is bigger, markers will be displayed as is. **/ maxZoom?: number; }; type DefaultProps = typeof defaultProps; declare const defaultProps: Readonly<{ tickTimeout: 200; }>; /** * Display clustered features on a map. * * @example * ```javascript * const clusterer = new YMapClusterer({ * method: clusterByGrid({gridSize: 64}), * features: POINTS, * marker: (feature) => new YMapMarker({ * coordinates: feature.geometry.coordinates, * source: 'my-source' * } * cluster: (coordinates, cluster) => new YMapMarker({ * coordinates, * source: 'my-source' * } * }); * * map.addChild(new YMapDefaultSchemeLayer()) * .addChild(new YMapFeatureDataSource({id: 'my-source'})) * .addChild(new YMapLayer({source: 'my-source', type: 'markers'})) * .addChild(clusterer); * ``` */ declare class YMapClusterer extends ymaps3.YMapComplexEntity<YMapClustererProps, DefaultProps> { static defaultProps: Readonly<{ tickTimeout: 200; }>; static [ymaps3.overrideKeyReactify]: import("../../../reactify/reactify").CustomReactify<YMapClusterer, import("react").ForwardRefExoticComponent<{ features: Feature[]; maxZoom?: number | undefined; method: IClusterMethod; tickTimeout?: number | undefined; onRender?: ((clusters: ClustererObject[]) => false | void) | undefined; marker: (feature: Feature) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>; cluster: (coordinates: LngLat, features: Feature[]) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>; ref?: import("react").Ref<YMapEntity<{ features: Feature[]; maxZoom?: number | undefined; method: IClusterMethod; tickTimeout?: number | undefined; onRender?: ((clusters: ClustererObject[]) => false | void) | undefined; marker: (feature: Feature) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>; cluster: (coordinates: LngLat, features: Feature[]) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>; }, {}>> | undefined; key?: import("react").Key | null | undefined; }>>; static [ymaps3.overrideKeyVuefy]: import("../../../modules/vuefy").CustomVuefyFn<YMapClusterer>; static [ymaps3.optionsKeyVuefy]: import("../../../modules/vuefy").CustomVuefyOptions<YMapClusterer>; /** All created entities with cluster id*/ private _entitiesCache; /** Viewport entities with cluster id */ private _visibleEntities; /** Store to add entities on a map */ private _container; /** Listener on map update and resize */ private _mapListener; constructor(props: YMapClustererProps); /** * Compare feature coordinates with bounds. * Visible in x2 bounds. * * @param feature * @param bounds * @param projection * @returns either feature belongs to viewport or not */ private _isVisible; /** * Get entity from store or create it * * @param feature * @param entityId * @param length count of entities in the cluster * @returns ready to add to map entity */ private _getEntity; /** * Generate map of new entities based on returned from method objects * * @param nextViewportObjects clustered objects * @returns map of entities for new render */ private _getVisibleEntities; /** * Removes unnecessary entities and adds new to the map * * @param nextVisibleEntities new entities for matching with existing entities */ private _syncVisibleEntities; private _render; protected _onAttach(): void; protected _onDetach(): void; protected _onUpdate(): void; } export { YMapClusterer, YMapClustererProps };