import { Entity, Viewer, PointGraphics, PolylineGraphics, PolygonGraphics, EllipseGraphics, RectangleGraphics } from 'cesium'; import { EventType } from '@bin/subscriber'; import { EventArgs } from '@bin/typings/Event'; declare type OverrideEntityFunc = (this: Drawer, action: EventType, entity: Entity) => Entity | void; /** * @todo 为了防止产生侵入性bug,请在配置前确认相关事件是否可用,不再默认移除原生事件 */ export declare type OperationType = { /** * @desc 勾画开始事件 * @type EventType * @default LEFT_CLICK */ START?: EventType; /** * @desc 勾画移动事件 * @type EventType * @default MOUSE_MOVE */ MOVING?: EventType; /** * @desc 勾画结束事件 * @type EventType * @default RIGHT_CLICK */ END?: EventType; /** * @desc 勾画销毁事件 * @type EventType * @default MIDDLE_CLICK */ DESTROY?: EventType; }; export declare type DrawerCallback = (entity: Entity) => void; /** * @desc 操作回调 * @param action 事件名 * @param move 事件参数 */ export declare type ActionCallback = (this: Drawer, action: EventType, move: EventArgs) => void; declare type Status = 'INIT' | 'START' | 'PAUSE' | 'DESTROY'; export interface DrawOption { /** * @desc 勾画的视图 */ viewer: Viewer; /** * @desc 是否使用地形,当开启时需要浏览器支持地形选取功能,如果不支持将会被关闭 */ terrain?: boolean; /** * @desc 操作方式 */ operateType?: OperationType; dynamicGraphicsOptions?: { POINT?: PointGraphics.ConstructorOptions; POLYLINE?: PolylineGraphics.ConstructorOptions; POLYGON?: PolygonGraphics.ConstructorOptions; CIRCLE?: EllipseGraphics.ConstructorOptions; RECTANGLE?: RectangleGraphics.ConstructorOptions; }; action?: ActionCallback; sameStyle?: boolean; } declare type StartOption = { /** * @desc 勾画类型 目前支持 Polygon、Line、Point、Circle、Rectangle * @default false */ type: 'POLYGON' | 'POLYLINE' | 'POINT' | 'CIRCLE' | 'RECTANGLE'; /** * 是否只勾画一次,如果设为true,则在第一勾画结束时停止 * @default undefined */ once?: boolean; /** * @desc 是否使用单例模式,如果开启,当勾画第二个图形时会销毁第一个图形 */ oneInstance?: boolean; /** * @desc 勾画的Entity选项,如Point对应#PointGraphics.ConstructorOptions */ options?: object; /** * @desc 动态勾画没有确定图形时的图形配置,类型与options选项相同 */ dynamicOptions?: object; }; export default class Drawer { private _viewer; private _type; private _terrain; private _subscriber; private _status; private _painter; private _events; private _typeClass; private _option; private $Instance; private _dynamicGraphicsOptions; private _dropPoint; private _moving; private _playOff; private _reset; /** * @desc 操作方式 */ private _operateType; /** * */ private _startOptions; private _oneInstance; private _once; /** * @desc 动作回调 */ private _action; private _sameStyle; get status(): Status; get isDestroy(): boolean; constructor(options: DrawOption); /** * @param extraOptions * @param dynamicOptions */ private _initPainter; /** * @desc 绘制函数, * @param config 绘制配置,可以通过定义options直接改写结果而不再填第二个参数 * @param overrideFunc Entity 重写函数,用于重写绘制结果,如果 overrideFunc返回一个Entity,则将该Entity添加到Viewer中,否则结束函数无操作 * @returns */ start(config: StartOption, overrideFunc?: OverrideEntityFunc): void; private _complete; private _isSupport; pause(): void; destroy(): void; } export {};