import type { IControl, IControlService, IGlobalConfigService, ILayerService, IMapletService, IMapService, IRendererService, PositionName, RaContainer } from '@ramap/ra-core'; import { PositionType } from '@ramap/ra-core'; import EventEmitter from 'eventemitter3'; import type { ControlEvent } from '../../interface'; export { PositionType } from '@ramap/ra-core'; export { Control }; export interface IControlOption { name: string; position: PositionName | Element; className?: string; style?: string; } export default class Control extends EventEmitter implements IControl { /** * 当前类型控件实例个数 * @protected */ protected static controlCount: number; /** * 当前控件实例配置 */ controlOption: O; /** * 控件的 DOM 容器 * @protected */ protected container: HTMLElement; /** * 当前控件是否显示 * @protected */ protected isShow: boolean; protected mapletContainer: RaContainer; protected maplet: IMapletService; protected mapsService: IMapService; protected renderService: IRendererService; protected layerService: ILayerService; protected controlService: IControlService; protected configService: IGlobalConfigService; constructor(option?: Partial); getOptions(): O; /** * 更新配置的方法,子类如果有自己的配置,也需要重写该方法 * @param newOptions */ setOptions(newOptions: Partial): void; /** * 当 Control 被添加至 Maplet 中,被 controlService 调用的方法 * @param mapletContainer */ addTo(mapletContainer: RaContainer): this; /** * 将控件移除时触发 */ remove(): this | undefined; /** * Control 被添加的时候被调用,返回 Control 对应的 DOM 容器 */ onAdd(): HTMLElement; /** * Control 被移除时调用 */ onRemove(): void; /** * 显示控件时触发 */ show(): void; /** * 隐藏控件时触发 */ hide(): void; /** * 获取默认构造器参数 */ getDefault(option?: Partial): O; /** * 获取当前控件对应的 DOM 容器 */ getContainer(): HTMLElement; /** * 获取当前 Control 是否展示 */ getIsShow(): boolean; _refocusOnMap(e: MouseEvent): void; /** * 设置当前控件位置 * @param position */ setPosition(position?: PositionType | IControlOption['position']): this; /** * 设置容器 container 的样式相关位置,包含 className * @param className */ setClassName(className?: string | null): void; /** * 设置容器 container 的样式相关位置,包含 style * @param style */ setStyle(style?: string | null): void; /** * 将控件 DOM 插入到对应 position 的容器中 * @protected */ protected insertContainer(): void; /** * 检查当前传入 option 是否包含 keys 字段 * @param option * @param keys * @protected */ protected checkUpdateOption(option: Partial, keys: Array): boolean; }