@yandex/ymaps3-types
Version: 
Types for ymaps3 maps library
103 lines (102 loc) • 3.44 kB
TypeScript
import { DrawingStyle, LngLat, YMapComplexEntity, YMapMarkerEventHandler } from "../../imperative";
export declare const TYPE_RULER = "ruler";
export declare const TYPE_PLANIMETER = "planimeter";
export type RulerType = typeof TYPE_RULER | typeof TYPE_PLANIMETER;
export type Measurements = RulerMeasurements | PlanimeterMeasurements;
export type RulerMeasurements = {
    type: typeof TYPE_RULER;
    /** the distance in meters from the first point of the line */
    distance: number;
    /** the distance in meters from the previous point of the line */
    segmentDistance: number;
    /** the total distance of the line in meters */
    totalDistance: number;
};
export type PlanimeterMeasurements = {
    type: typeof TYPE_PLANIMETER;
    /** the area of the closed line shape in square meters */
    area: number;
};
export type CommonMeasurements = Omit<RulerMeasurements, "distance" | "segmentDistance"> | PlanimeterMeasurements;
export type RulerPointState = {
    index: number;
    totalCount: number;
    coordinates: LngLat;
    measurements: Measurements;
    editable: boolean;
    source: string;
};
export type RulerCommonState = {
    measurements: CommonMeasurements;
    points: LngLat[];
};
export type RenderPointCommon = (params: RenderPointCommonArgs) => RenderPointCommonResult;
export type RenderPointCommonArgs = {
    state: RulerPointState;
    onDragMove: YMapMarkerEventHandler;
    onDragStart: YMapMarkerEventHandler;
    onDragEnd: YMapMarkerEventHandler;
    onDelete: () => void;
};
export type RenderPointCommonResult = {
    update: (state: RulerPointState) => void;
    remove: (index: number) => void;
};
export type UpdateCommonFn = (commonState: RulerCommonState) => void;
export type UpdateStartFn = (commonState: {}) => void;
export type UpdateEndFn = (commonState: {}) => void;
export type RulerGeometry = {
    style: DrawingStyle;
};
export type YMapRulerCommonProps = {
    type: RulerType;
    points: LngLat[];
    editable?: boolean;
    geometry: RulerGeometry;
    source?: string;
    zIndex?: number;
    previewPoint: HTMLElement;
    point: RenderPointCommon;
    onUpdate?: UpdateCommonFn;
    onUpdateStart?: UpdateStartFn;
    onUpdateEnd?: UpdateEndFn;
};
export declare const defaultProps: Readonly<{
    editable: true;
    zIndex: 2600;
    source: "ymaps3x0-ruler";
}>;
export declare class YMapRulerCommon extends YMapComplexEntity<YMapRulerCommonProps, typeof defaultProps> {
    static defaultProps: Readonly<{
        editable: true;
        zIndex: 2600;
        source: "ymaps3x0-ruler";
    }>;
    private _lineFeature;
    private _polygonFeature;
    private _listener;
    private _previewPointMarker?;
    private _dataSource;
    private _markersLayer;
    private _featuresLayer;
    private _blockerLayer;
    private _rulerPoints;
    private _measurements;
    private _totalDistance;
    private _area;
    constructor(props: YMapRulerCommonProps);
    protected _onAttach(): void;
    protected _onDetach(): void;
    protected _onUpdate(props: Partial<YMapRulerCommonProps>): void;
    private _commonUpdate;
    private _updateRulerCoordinates;
    private _updateRulerGeometry;
    private _onMouseMoveHandler;
    private _onMouseMoveOnPreviewMarker;
    private _onClickHandler;
    private _createPreviewPointMarker;
    private _updateMeasurements;
    private _getFeaturesCoordinates;
    private _createNewRulerPoint;
    private _removeRulerPoint;
}