@orca-fe/x-map
Version:
42 lines (41 loc) • 1.63 kB
TypeScript
import { EventEmitter } from 'events';
import { MultiPolygon, Point as GeoJSONPoint } from '@turf/turf';
import { LineString, Polygon } from '@turf/helpers/dist/js/lib/geojson';
import { Point } from '../defs';
export declare type DrawEvents = {
'draw-start': () => void;
'draw-finish': () => void;
'draw-cancel': () => void;
'state-change': () => void;
};
export declare type DrawShapeType = 'point' | 'line' | 'polyline' | 'circle' | 'rect' | 'polygon' | 'multi-polygon';
export declare type DrawStateOptions = {
dom: HTMLElement;
pixelToLnglat: (point: Point) => Point;
};
export default class DrawState {
options: DrawStateOptions;
events: EventEmitter;
drawMode: false | DrawShapeType;
protected drawing: boolean;
constructor(options: DrawStateOptions);
protected getXY(e: MouseEvent): Point;
protected registerEvents(): void;
destroy(): void;
begin(type: DrawShapeType): void;
stop(): void;
cancel(): void;
on<T extends keyof DrawEvents>(eventName: T, callback: DrawEvents[T]): void;
off<T extends keyof DrawEvents>(eventName: T, callback: DrawEvents[T]): void;
protected mousedownXY: Point;
protected mousedownPosition: Point;
protected currentPosition: Point;
protected positionArr: Point[];
protected multiPositionArr: Point[][];
mousedown: boolean;
onMouseDown: (e: MouseEvent) => void;
onMouseMove: (e: MouseEvent) => void;
onMouseUp: (e: MouseEvent) => void;
onDoubleClick: () => void;
getGeoJson(): MultiPolygon | Polygon | GeoJSONPoint | LineString | null;
}