@xingm/vmap-cesium-toolbar 0.0.5 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +126 -230
- package/dist/README.md +172 -0
- package/dist/adapters/DrawHelperAdapter.d.ts +143 -0
- package/dist/adapters/MapLoaderAdapter.d.ts +44 -0
- package/dist/adapters/OverlayServiceAdapter.d.ts +102 -0
- package/dist/adapters/ToolbarAdapter.d.ts +71 -0
- package/dist/adapters/index.d.ts +23 -0
- package/dist/components/BaseComponent.d.ts +116 -0
- package/dist/components/SearchBox.d.ts +136 -0
- package/dist/components/Toolbar.d.ts +115 -0
- package/dist/components/ToolbarButton.d.ts +100 -0
- package/dist/components/index.d.ts +33 -0
- package/dist/core/MapPlugin.d.ts +160 -0
- package/dist/core/constants.d.ts +88 -0
- package/dist/core/entities/BaseOverlay.d.ts +156 -0
- package/dist/core/entities/Circle.d.ts +102 -0
- package/dist/core/entities/Icon.d.ts +86 -0
- package/dist/core/entities/InfoWindow.d.ts +116 -0
- package/dist/core/entities/Label.d.ts +92 -0
- package/dist/core/entities/Marker.d.ts +66 -0
- package/dist/core/entities/Polygon.d.ts +93 -0
- package/dist/core/entities/Polyline.d.ts +72 -0
- package/dist/core/entities/Rectangle.d.ts +99 -0
- package/dist/core/entities/Ring.d.ts +114 -0
- package/dist/core/entities/SVG.d.ts +89 -0
- package/dist/core/entities/index.d.ts +27 -0
- package/dist/core/index.d.ts +25 -0
- package/dist/core/layers/BaiduMapLayer.d.ts +37 -0
- package/dist/core/layers/CustomMapLayer.d.ts +43 -0
- package/dist/core/layers/GaodeMapLayer.d.ts +41 -0
- package/dist/core/layers/HeatmapLayer.d.ts +118 -0
- package/dist/core/layers/MapLayer.d.ts +37 -0
- package/dist/core/layers/OSMMapLayer.d.ts +37 -0
- package/dist/core/layers/PointClusterLayer.d.ts +119 -0
- package/dist/core/layers/TDTMapLayer.d.ts +45 -0
- package/dist/core/layers/index.d.ts +15 -0
- package/dist/core/services/draw/DrawInteractionController.d.ts +16 -0
- package/dist/core/services/draw/DrawService.d.ts +38 -0
- package/dist/core/services/draw/DrawSessionStore.d.ts +28 -0
- package/dist/core/services/draw/drawDefaults.d.ts +16 -0
- package/dist/core/services/draw/entities/drawEntityFactory.d.ts +10 -0
- package/dist/core/services/draw/entities/drawEntityRegistry.d.ts +8 -0
- package/dist/core/services/draw/entities/drawFinalFactory.d.ts +14 -0
- package/dist/core/services/draw/entities/drawPreviewFactory.d.ts +15 -0
- package/dist/core/services/draw/geometry/drawGeometry.d.ts +11 -0
- package/dist/core/services/draw/geometry/drawPosition.d.ts +6 -0
- package/dist/core/services/draw/index.d.ts +7 -0
- package/dist/core/services/draw/labels/drawHint.d.ts +16 -0
- package/dist/core/services/draw/labels/measurementCanvas.d.ts +8 -0
- package/dist/core/services/draw/labels/measurementLabelFactory.d.ts +18 -0
- package/dist/core/services/draw/measurementThemeResolver.d.ts +9 -0
- package/dist/core/services/draw/types/drawState.d.ts +37 -0
- package/dist/core/services/draw/types/drawTypes.d.ts +97 -0
- package/dist/core/services/index.d.ts +10 -0
- package/dist/core/services/overlay/OverlayService.d.ts +188 -0
- package/dist/core/services/overlay/index.d.ts +7 -0
- package/dist/core/services/toolbar/ToolbarService.d.ts +175 -0
- package/dist/core/services/toolbar/buttons/BaseButtonHandler.d.ts +111 -0
- package/dist/core/services/toolbar/buttons/LayersButtonHandler.d.ts +47 -0
- package/dist/core/services/toolbar/buttons/MeasureButtonHandler.d.ts +94 -0
- package/dist/core/services/toolbar/buttons/SearchButtonHandler.d.ts +111 -0
- package/dist/core/services/toolbar/buttons/SimpleButtonHandler.d.ts +79 -0
- package/dist/core/services/toolbar/config.d.ts +7 -0
- package/dist/core/services/toolbar/index.d.ts +30 -0
- package/dist/core/services/toolbar/menus/BaseMenu.d.ts +99 -0
- package/dist/core/services/toolbar/menus/MeasureMenu.d.ts +44 -0
- package/dist/core/services/toolbar/types.d.ts +198 -0
- package/dist/core/types.d.ts +586 -0
- package/dist/i18n/en-US.d.ts +46 -0
- package/dist/i18n/index.d.ts +45 -2
- package/dist/i18n/zh-CN.d.ts +46 -0
- package/dist/index.d.ts +37 -42
- package/dist/index.es.js +7056 -9844
- package/dist/index.es.js.map +1 -1
- package/dist/libs/CesiumMapModel.d.ts +1 -172
- package/dist/libs/CesiumMapToolbar.d.ts +1 -1
- package/dist/libs/CesiumOverlayService.d.ts +9 -222
- package/dist/libs/config/CesiumMapConfig.d.ts +5 -12
- package/dist/libs/drawHelper/DrawHint.d.ts +15 -27
- package/dist/libs/drawHelper/index.d.ts +67 -6
- package/dist/libs/toolBar/CesiumMapController.d.ts +38 -64
- package/dist/libs/toolBar/MapLayersService.d.ts +10 -61
- package/dist/libs/toolBar/MapSearchService.d.ts +8 -29
- package/dist/libs/toolBar/MapToolBarConfig.d.ts +33 -5
- package/dist/libs/toolBar/MeasurementService.d.ts +13 -5
- package/dist/libs/toolBar/NotFlyZonesService.d.ts +6 -41
- package/dist/package.json +19 -6
- package/dist/styles/ComponentStyles.d.ts +82 -0
- package/dist/styles/StyleManager.d.ts +142 -0
- package/dist/styles/index.d.ts +128 -0
- package/dist/utils/common.d.ts +4 -0
- package/package.json +1 -1
- package/dist/hooks/toolBarConfig.d.ts +0 -75
- package/dist/hooks/useDrawHelper.d.ts +0 -24
- package/dist/hooks/useDynamicRing.d.ts +0 -44
- package/dist/hooks/useHeatmapHelper.d.ts +0 -18
- package/dist/hooks/useMap.d.ts +0 -14
- package/dist/hooks/useMapInit.d.ts +0 -14
- package/dist/hooks/useOverlayHelper.d.ts +0 -48
- package/dist/hooks/usePointClusterHelper.d.ts +0 -14
- package/dist/index.umd.js +0 -326
- package/dist/index.umd.js.map +0 -1
- package/dist/libs/drawHelper/BaseDraw.d.ts +0 -194
- package/dist/libs/drawHelper/DrawCircle.d.ts +0 -31
- package/dist/libs/drawHelper/DrawLine.d.ts +0 -49
- package/dist/libs/drawHelper/DrawPolgon.d.ts +0 -35
- package/dist/libs/drawHelper/DrawRectangle.d.ts +0 -24
- package/dist/libs/i18n/en-US.d.ts +0 -69
- package/dist/libs/i18n/index.d.ts +0 -25
- package/dist/libs/i18n/zh-CN.d.ts +0 -69
- package/dist/libs/overlay/MapCircle.d.ts +0 -130
- package/dist/libs/overlay/MapIcon.d.ts +0 -69
- package/dist/libs/overlay/MapInfoWindow.d.ts +0 -100
- package/dist/libs/overlay/MapLabel.d.ts +0 -73
- package/dist/libs/overlay/MapMarker.d.ts +0 -60
- package/dist/libs/overlay/MapPolygon.d.ts +0 -114
- package/dist/libs/overlay/MapPolyline.d.ts +0 -64
- package/dist/libs/overlay/MapRectangle.d.ts +0 -101
- package/dist/libs/overlay/MapRing.d.ts +0 -107
- package/dist/libs/overlay/MapSVG.d.ts +0 -73
- package/dist/libs/overlay/OverlayEditController.d.ts +0 -166
- package/dist/libs/overlay/OverlayEditHandles.d.ts +0 -101
- package/dist/libs/overlay/OverlayHighlight.d.ts +0 -40
- package/dist/libs/overlay/index.d.ts +0 -23
- package/dist/libs/overlay/primitives/CirclePrimitiveBatch.d.ts +0 -42
- package/dist/libs/overlay/primitives/CirclePrimitiveLayerStack.d.ts +0 -24
- package/dist/libs/overlay/primitives/PolygonPrimitiveBatch.d.ts +0 -43
- package/dist/libs/overlay/primitives/PolygonPrimitiveLayerStack.d.ts +0 -24
- package/dist/libs/overlay/primitives/RectanglePrimitiveBatch.d.ts +0 -41
- package/dist/libs/overlay/primitives/RectanglePrimitiveLayerStack.d.ts +0 -24
- package/dist/libs/overlay/types.d.ts +0 -121
- package/dist/z.const.d.ts +0 -24
- /package/dist/{libs → utils}/PickGovernor.d.ts +0 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { Viewer, Entity } from '../../../../node_modules/cesium';
|
|
2
|
+
import { Marker, MarkerOptions } from '../../entities/Marker';
|
|
3
|
+
import { Label, LabelOptions } from '../../entities/Label';
|
|
4
|
+
import { Icon, IconOptions } from '../../entities/Icon';
|
|
5
|
+
import { SVG, SvgOptions } from '../../entities/SVG';
|
|
6
|
+
import { InfoWindow, InfoWindowOptions } from '../../entities/InfoWindow';
|
|
7
|
+
import { Polyline, PolylineOptions } from '../../entities/Polyline';
|
|
8
|
+
import { Polygon, PolygonOptions } from '../../entities/Polygon';
|
|
9
|
+
import { Rectangle, RectangleOptions } from '../../entities/Rectangle';
|
|
10
|
+
import { Circle, CircleOptions } from '../../entities/Circle';
|
|
11
|
+
import { Ring, RingOptions } from '../../entities/Ring';
|
|
12
|
+
import { OverlayEntity } from '../../entities/BaseOverlay';
|
|
13
|
+
type OverlayInstance = Marker | Label | Icon | SVG | InfoWindow | Polyline | Polygon | Rectangle | Circle | Ring;
|
|
14
|
+
/**
|
|
15
|
+
* 覆盖物服务选项
|
|
16
|
+
*/
|
|
17
|
+
export interface OverlayServiceOptions {
|
|
18
|
+
/** 是否启用 hover 处理器(默认 true) */
|
|
19
|
+
enableHoverHandler?: boolean;
|
|
20
|
+
/** 点击节流间隔(毫秒,默认 120) */
|
|
21
|
+
clickPickMinIntervalMs?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 覆盖物服务类
|
|
25
|
+
*
|
|
26
|
+
* 统一管理所有覆盖物的创建、更新和删除。
|
|
27
|
+
* 基于新的实体类架构,提供便捷的服务层 API。
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const overlayService = new OverlayService(viewer);
|
|
32
|
+
*
|
|
33
|
+
* // 添加标记
|
|
34
|
+
* const marker = overlayService.addMarker({
|
|
35
|
+
* position: [120.1, 30.2],
|
|
36
|
+
* pixelSize: 12,
|
|
37
|
+
* color: '#FF0000'
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* // 添加多边形
|
|
41
|
+
* const polygon = overlayService.addPolygon({
|
|
42
|
+
* positions: [[120.1, 30.2], [120.2, 30.3], [120.3, 30.25]],
|
|
43
|
+
* material: 'rgba(255, 0, 0, 0.3)'
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* // 根据 ID 获取覆盖物
|
|
47
|
+
* const m = overlayService.getOverlay(marker.getId());
|
|
48
|
+
*
|
|
49
|
+
* // 删除覆盖物
|
|
50
|
+
* overlayService.removeOverlay(marker.getId());
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare class OverlayService {
|
|
54
|
+
private viewer;
|
|
55
|
+
private overlays;
|
|
56
|
+
private entityOverlayMap;
|
|
57
|
+
private options;
|
|
58
|
+
private nextId;
|
|
59
|
+
private clickHandler;
|
|
60
|
+
private hoverHandler;
|
|
61
|
+
private clickHighlightTargets;
|
|
62
|
+
private hoverHighlightTargets;
|
|
63
|
+
private lastClickPickAt;
|
|
64
|
+
private pendingHoverRaf;
|
|
65
|
+
private pendingHoverPosition;
|
|
66
|
+
private readonly highlightCache;
|
|
67
|
+
private markerFactory;
|
|
68
|
+
private labelFactory;
|
|
69
|
+
private iconFactory;
|
|
70
|
+
private svgFactory;
|
|
71
|
+
private infoWindowFactory;
|
|
72
|
+
private polylineFactory;
|
|
73
|
+
private polygonFactory;
|
|
74
|
+
private rectangleFactory;
|
|
75
|
+
private circleFactory;
|
|
76
|
+
private ringFactory;
|
|
77
|
+
constructor(viewer: Viewer, options?: OverlayServiceOptions);
|
|
78
|
+
/**
|
|
79
|
+
* 生成唯一 ID
|
|
80
|
+
*/
|
|
81
|
+
generateId(prefix?: string): string;
|
|
82
|
+
/**
|
|
83
|
+
* 注册覆盖物
|
|
84
|
+
*/
|
|
85
|
+
registerOverlay(id: string, overlay: OverlayInstance): void;
|
|
86
|
+
/**
|
|
87
|
+
* 注销覆盖物
|
|
88
|
+
*/
|
|
89
|
+
unregisterOverlay(id: string): void;
|
|
90
|
+
/**
|
|
91
|
+
* 根据 ID 获取覆盖物
|
|
92
|
+
*/
|
|
93
|
+
getOverlay(id: string): OverlayInstance | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* 获取所有覆盖物 ID
|
|
96
|
+
*/
|
|
97
|
+
getAllOverlayIds(): string[];
|
|
98
|
+
/**
|
|
99
|
+
* 添加 Marker
|
|
100
|
+
*/
|
|
101
|
+
addMarker(options: MarkerOptions): Marker;
|
|
102
|
+
/**
|
|
103
|
+
* 添加 Label
|
|
104
|
+
*/
|
|
105
|
+
addLabel(options: LabelOptions): Label;
|
|
106
|
+
/**
|
|
107
|
+
* 添加 Icon
|
|
108
|
+
*/
|
|
109
|
+
addIcon(options: IconOptions): Icon;
|
|
110
|
+
/**
|
|
111
|
+
* 添加 SVG
|
|
112
|
+
*/
|
|
113
|
+
addSvg(options: SvgOptions): SVG;
|
|
114
|
+
/**
|
|
115
|
+
* 添加 InfoWindow
|
|
116
|
+
*/
|
|
117
|
+
addInfoWindow(options: InfoWindowOptions): InfoWindow;
|
|
118
|
+
/**
|
|
119
|
+
* 添加 Polyline
|
|
120
|
+
*/
|
|
121
|
+
addPolyline(options: PolylineOptions): Polyline;
|
|
122
|
+
/**
|
|
123
|
+
* 添加 Polygon
|
|
124
|
+
*/
|
|
125
|
+
addPolygon(options: PolygonOptions): Polygon;
|
|
126
|
+
/**
|
|
127
|
+
* 添加 Rectangle
|
|
128
|
+
*/
|
|
129
|
+
addRectangle(options: RectangleOptions): Rectangle;
|
|
130
|
+
/**
|
|
131
|
+
* 添加 Circle
|
|
132
|
+
*/
|
|
133
|
+
addCircle(options: CircleOptions): Circle;
|
|
134
|
+
/**
|
|
135
|
+
* 添加 Ring
|
|
136
|
+
*/
|
|
137
|
+
addRing(options: RingOptions): Ring;
|
|
138
|
+
/**
|
|
139
|
+
* 根据 ID 删除覆盖物
|
|
140
|
+
*/
|
|
141
|
+
removeOverlay(id: string): boolean;
|
|
142
|
+
/**
|
|
143
|
+
* 删除所有覆盖物
|
|
144
|
+
*/
|
|
145
|
+
removeAllOverlays(): void;
|
|
146
|
+
/**
|
|
147
|
+
* 设置覆盖物可见性
|
|
148
|
+
*/
|
|
149
|
+
setOverlayVisible(id: string, visible: boolean): boolean;
|
|
150
|
+
/**
|
|
151
|
+
* 显式切换覆盖物高亮状态。
|
|
152
|
+
*/
|
|
153
|
+
toggleOverlayHighlight(entityOrId: OverlayEntity | Entity | string, reason?: 'click' | 'hover'): boolean;
|
|
154
|
+
/**
|
|
155
|
+
* 显式设置覆盖物高亮状态。
|
|
156
|
+
*/
|
|
157
|
+
setOverlayHighlight(entityOrId: OverlayEntity | Entity | string, enabled: boolean, reason?: 'click' | 'hover'): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* 安装 Hover 处理器
|
|
160
|
+
*/
|
|
161
|
+
private setupHoverHandler;
|
|
162
|
+
/**
|
|
163
|
+
* 安装点击处理器
|
|
164
|
+
*/
|
|
165
|
+
private setupClickHandler;
|
|
166
|
+
private bindOverlayEntities;
|
|
167
|
+
private unbindOverlayEntities;
|
|
168
|
+
private collectOverlayEntities;
|
|
169
|
+
private pickOverlayEntity;
|
|
170
|
+
private safeDrillPick;
|
|
171
|
+
private resolvePickedOverlayEntity;
|
|
172
|
+
private resolveOverlayEntity;
|
|
173
|
+
private getHighlightTargets;
|
|
174
|
+
private setHighlightTargets;
|
|
175
|
+
private setEntityHighlight;
|
|
176
|
+
private isHighlightActive;
|
|
177
|
+
private clearOverlayHighlightState;
|
|
178
|
+
private normalizeHighlightOptions;
|
|
179
|
+
private resolveHighlightColor;
|
|
180
|
+
private applyEntityHighlight;
|
|
181
|
+
private restoreEntityStyle;
|
|
182
|
+
private captureEntityStyle;
|
|
183
|
+
/**
|
|
184
|
+
* 销毁服务
|
|
185
|
+
*/
|
|
186
|
+
destroy(): void;
|
|
187
|
+
}
|
|
188
|
+
export {};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { Toolbar } from '../../../components/Toolbar';
|
|
2
|
+
import { CustomButtonConfig, LayersPanelStyleConfig, SearchPanelStyleConfig, ToolbarConfig as CoreToolbarConfig } from '../../../core/types';
|
|
3
|
+
import { IButtonHandler, ToolbarServiceConfig, MeasurementServiceLike } from './types';
|
|
4
|
+
import { MapControllerLike } from './buttons/SimpleButtonHandler';
|
|
5
|
+
/**
|
|
6
|
+
* 工具栏服务配置扩展
|
|
7
|
+
* 支持自定义工具栏样式和按钮配置
|
|
8
|
+
*/
|
|
9
|
+
export interface ToolbarServiceOptions {
|
|
10
|
+
/** 工具栏样式配置 */
|
|
11
|
+
toolbarStyle?: Partial<CoreToolbarConfig>;
|
|
12
|
+
/** 按钮配置列表(覆盖默认配置) */
|
|
13
|
+
buttonConfigs?: CustomButtonConfig[];
|
|
14
|
+
/** 是否使用默认按钮 */
|
|
15
|
+
useDefaultButtons?: boolean;
|
|
16
|
+
/** 搜索面板样式 */
|
|
17
|
+
searchPanelStyle?: SearchPanelStyleConfig;
|
|
18
|
+
/** 搜索面板默认动作图标 */
|
|
19
|
+
searchIdleActionIcon?: string | HTMLElement;
|
|
20
|
+
/** 搜索面板清空动作图标 */
|
|
21
|
+
searchClearActionIcon?: string | HTMLElement;
|
|
22
|
+
/** 图层菜单样式 */
|
|
23
|
+
layersPanelStyle?: LayersPanelStyleConfig;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 工具栏服务类
|
|
27
|
+
*/
|
|
28
|
+
export declare class ToolbarService {
|
|
29
|
+
/** 工具栏 UI 组件 */
|
|
30
|
+
private toolbar;
|
|
31
|
+
/** 按钮处理器映射表 */
|
|
32
|
+
private buttonHandlers;
|
|
33
|
+
/** 配置 */
|
|
34
|
+
private config;
|
|
35
|
+
/** 国际化实例 */
|
|
36
|
+
private i18n?;
|
|
37
|
+
/** 是否使用国际化 */
|
|
38
|
+
private useI18n;
|
|
39
|
+
/** 地图控制器 */
|
|
40
|
+
private mapController?;
|
|
41
|
+
/** 测量服务实例 */
|
|
42
|
+
private measurementService?;
|
|
43
|
+
/** 搜索服务实例 */
|
|
44
|
+
private searchService?;
|
|
45
|
+
/** 图层服务实例 */
|
|
46
|
+
private layersService?;
|
|
47
|
+
/** 绘图助手实例 */
|
|
48
|
+
private drawHelper?;
|
|
49
|
+
/** 工具栏服务选项 */
|
|
50
|
+
private options;
|
|
51
|
+
private buttonConfigs?;
|
|
52
|
+
private unsubscribeI18n?;
|
|
53
|
+
/**
|
|
54
|
+
* 构造函数
|
|
55
|
+
* @param config 工具栏服务配置
|
|
56
|
+
* @param options 工具栏服务选项
|
|
57
|
+
*/
|
|
58
|
+
constructor(config: ToolbarServiceConfig, options?: ToolbarServiceOptions);
|
|
59
|
+
/**
|
|
60
|
+
* 初始化工具栏
|
|
61
|
+
*/
|
|
62
|
+
initialize(): void;
|
|
63
|
+
private setupLocaleSync;
|
|
64
|
+
/**
|
|
65
|
+
* 创建工具栏 UI
|
|
66
|
+
*/
|
|
67
|
+
private createToolbar;
|
|
68
|
+
/**
|
|
69
|
+
* 注册默认按钮处理器
|
|
70
|
+
*/
|
|
71
|
+
private registerDefaultButtonHandlers;
|
|
72
|
+
/**
|
|
73
|
+
* 初始化按钮
|
|
74
|
+
*/
|
|
75
|
+
private initializeButtons;
|
|
76
|
+
/**
|
|
77
|
+
* 注册按钮处理器
|
|
78
|
+
* @param handler 按钮处理器
|
|
79
|
+
*/
|
|
80
|
+
registerButtonHandler(handler: IButtonHandler): void;
|
|
81
|
+
/**
|
|
82
|
+
* 获取按钮处理器
|
|
83
|
+
* @param id 按钮 ID
|
|
84
|
+
*/
|
|
85
|
+
getButtonHandler(id: string): IButtonHandler | null;
|
|
86
|
+
/**
|
|
87
|
+
* 移除按钮处理器
|
|
88
|
+
* @param id 按钮 ID
|
|
89
|
+
*/
|
|
90
|
+
unregisterButtonHandler(id: string): void;
|
|
91
|
+
/**
|
|
92
|
+
* 添加自定义按钮
|
|
93
|
+
* @param config 自定义按钮配置
|
|
94
|
+
* @param onClick 点击回调
|
|
95
|
+
*/
|
|
96
|
+
addCustomButton(config: CustomButtonConfig, onClick?: (buttonId: string, buttonElement: HTMLElement) => void): void;
|
|
97
|
+
/**
|
|
98
|
+
* 移除按钮
|
|
99
|
+
* @param buttonId 按钮 ID
|
|
100
|
+
*/
|
|
101
|
+
removeButton(buttonId: string): void;
|
|
102
|
+
/**
|
|
103
|
+
* 更新按钮配置
|
|
104
|
+
* @param buttonId 按钮 ID
|
|
105
|
+
* @param config 新的按钮配置
|
|
106
|
+
*/
|
|
107
|
+
updateButton(buttonId: string, config: Partial<CustomButtonConfig>): void;
|
|
108
|
+
/**
|
|
109
|
+
* 更新工具栏样式,避免业务层重新初始化工具栏。
|
|
110
|
+
*/
|
|
111
|
+
updateToolbarStyle(config: Partial<CoreToolbarConfig>): void;
|
|
112
|
+
/**
|
|
113
|
+
* 启用按钮
|
|
114
|
+
* @param buttonId 按钮 ID
|
|
115
|
+
*/
|
|
116
|
+
enableButton(buttonId: string): void;
|
|
117
|
+
/**
|
|
118
|
+
* 禁用按钮
|
|
119
|
+
* @param buttonId 按钮 ID
|
|
120
|
+
*/
|
|
121
|
+
disableButton(buttonId: string): void;
|
|
122
|
+
/**
|
|
123
|
+
* 显示按钮
|
|
124
|
+
* @param buttonId 按钮 ID
|
|
125
|
+
*/
|
|
126
|
+
showButton(buttonId: string): void;
|
|
127
|
+
/**
|
|
128
|
+
* 隐藏按钮
|
|
129
|
+
* @param buttonId 按钮 ID
|
|
130
|
+
*/
|
|
131
|
+
hideButton(buttonId: string): void;
|
|
132
|
+
/**
|
|
133
|
+
* 设置测量服务
|
|
134
|
+
* @param service 测量服务实例
|
|
135
|
+
*/
|
|
136
|
+
setMeasurementService(service: MeasurementServiceLike): void;
|
|
137
|
+
/**
|
|
138
|
+
* 设置搜索服务
|
|
139
|
+
* @param service 搜索服务实例
|
|
140
|
+
*/
|
|
141
|
+
setSearchService(service: any): void;
|
|
142
|
+
/**
|
|
143
|
+
* 设置图层服务
|
|
144
|
+
* @param service 图层服务实例
|
|
145
|
+
*/
|
|
146
|
+
setLayersService(service: any): void;
|
|
147
|
+
/**
|
|
148
|
+
* 设置地图控制器
|
|
149
|
+
* @param controller 地图控制器
|
|
150
|
+
*/
|
|
151
|
+
setMapController(controller: MapControllerLike): void;
|
|
152
|
+
/**
|
|
153
|
+
* 获取工具栏 UI 组件
|
|
154
|
+
*/
|
|
155
|
+
getToolbar(): Toolbar | null;
|
|
156
|
+
/**
|
|
157
|
+
* 获取工具栏容器元素
|
|
158
|
+
*/
|
|
159
|
+
getToolbarElement(): HTMLElement | null;
|
|
160
|
+
/**
|
|
161
|
+
* 关闭所有打开的菜单
|
|
162
|
+
*/
|
|
163
|
+
closeAllMenus(): void;
|
|
164
|
+
/**
|
|
165
|
+
* 销毁工具栏服务
|
|
166
|
+
*/
|
|
167
|
+
destroy(): void;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* 创建工具栏服务的工厂函数
|
|
171
|
+
* @param config 工具栏服务配置
|
|
172
|
+
* @param options 工具栏服务选项
|
|
173
|
+
* @returns 工具栏服务实例
|
|
174
|
+
*/
|
|
175
|
+
export declare function createToolbarService(config: ToolbarServiceConfig, options?: ToolbarServiceOptions): ToolbarService;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { ToolbarButton } from '../../../../components/ToolbarButton';
|
|
2
|
+
import { IButtonHandler } from '../types';
|
|
3
|
+
import { I18nLike } from '../../../../i18n';
|
|
4
|
+
/**
|
|
5
|
+
* 按钮处理器基类
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class BaseButtonHandler implements IButtonHandler {
|
|
8
|
+
/** 按钮 ID */
|
|
9
|
+
readonly id: string;
|
|
10
|
+
/** 按钮实例引用 */
|
|
11
|
+
protected button: ToolbarButton | null;
|
|
12
|
+
/** 国际化实例 */
|
|
13
|
+
protected i18n?: I18nLike;
|
|
14
|
+
/** 是否使用国际化 */
|
|
15
|
+
protected useI18n: boolean;
|
|
16
|
+
/** Cesium Viewer 实例 */
|
|
17
|
+
protected viewer: any;
|
|
18
|
+
/** 工具栏容器元素 */
|
|
19
|
+
protected toolbarElement: HTMLElement | null;
|
|
20
|
+
/**
|
|
21
|
+
* 构造函数
|
|
22
|
+
* @param id 按钮 ID
|
|
23
|
+
* @param viewer Cesium Viewer 实例
|
|
24
|
+
* @param i18n 国际化实例
|
|
25
|
+
* @param useI18n 是否使用国际化
|
|
26
|
+
*/
|
|
27
|
+
constructor(id: string, viewer: any, i18n?: I18nLike, useI18n?: boolean);
|
|
28
|
+
/**
|
|
29
|
+
* 初始化按钮(由子类实现)
|
|
30
|
+
* @param button 按钮实例
|
|
31
|
+
*/
|
|
32
|
+
abstract initialize(button: ToolbarButton): void;
|
|
33
|
+
/**
|
|
34
|
+
* 处理点击事件(由子类实现)
|
|
35
|
+
*/
|
|
36
|
+
abstract handleClick(): void;
|
|
37
|
+
/**
|
|
38
|
+
* 处理鼠标进入事件(可选,由子类实现)
|
|
39
|
+
*/
|
|
40
|
+
handleMouseEnter?(): void;
|
|
41
|
+
/**
|
|
42
|
+
* 处理鼠标离开事件(可选,由子类实现)
|
|
43
|
+
*/
|
|
44
|
+
handleMouseLeave?(): void;
|
|
45
|
+
/**
|
|
46
|
+
* 销毁处理器(由子类实现)
|
|
47
|
+
*/
|
|
48
|
+
abstract destroy(): void;
|
|
49
|
+
/**
|
|
50
|
+
* 设置工具栏容器元素
|
|
51
|
+
* @param element 工具栏容器元素
|
|
52
|
+
*/
|
|
53
|
+
setToolbarElement(element: HTMLElement): void;
|
|
54
|
+
/**
|
|
55
|
+
* 获取按钮实例
|
|
56
|
+
*/
|
|
57
|
+
getButton(): ToolbarButton | null;
|
|
58
|
+
/**
|
|
59
|
+
* 激活按钮
|
|
60
|
+
*/
|
|
61
|
+
protected activateButton(): void;
|
|
62
|
+
/**
|
|
63
|
+
* 取消激活按钮
|
|
64
|
+
*/
|
|
65
|
+
protected deactivateButton(): void;
|
|
66
|
+
/**
|
|
67
|
+
* 切换按钮激活状态
|
|
68
|
+
*/
|
|
69
|
+
protected toggleButtonActive(): void;
|
|
70
|
+
/**
|
|
71
|
+
* 检查按钮是否激活
|
|
72
|
+
*/
|
|
73
|
+
protected isButtonActive(): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* 翻译文本
|
|
76
|
+
* @param key 翻译键
|
|
77
|
+
* @param params 翻译参数
|
|
78
|
+
*/
|
|
79
|
+
protected t(key: string, params?: Record<string, any>): string;
|
|
80
|
+
/**
|
|
81
|
+
* 绑定元素翻译
|
|
82
|
+
* @param element DOM 元素
|
|
83
|
+
* @param key 翻译键
|
|
84
|
+
* @param attribute 属性名(默认为 textContent)
|
|
85
|
+
*/
|
|
86
|
+
protected bindElement(element: HTMLElement, key: string, attribute?: string): void;
|
|
87
|
+
/**
|
|
88
|
+
* 创建菜单项元素
|
|
89
|
+
* @param id 菜单项 ID
|
|
90
|
+
* @param text 显示文本
|
|
91
|
+
* @param icon 图标
|
|
92
|
+
* @param onClick 点击回调
|
|
93
|
+
*/
|
|
94
|
+
protected createMenuItem(id: string, text: string, icon: string, onClick: () => void): HTMLElement;
|
|
95
|
+
/**
|
|
96
|
+
* 关闭其他打开的菜单
|
|
97
|
+
* @param excludeId 排除的按钮 ID
|
|
98
|
+
*/
|
|
99
|
+
protected closeOtherMenus(excludeId?: string): void;
|
|
100
|
+
/**
|
|
101
|
+
* 延迟关闭菜单
|
|
102
|
+
* @param menu 菜单元素
|
|
103
|
+
* @param delay 延迟时间(毫秒)
|
|
104
|
+
*/
|
|
105
|
+
protected scheduleMenuClose(menu: HTMLElement, delay?: number): void;
|
|
106
|
+
/**
|
|
107
|
+
* 调整菜单位置以避免超出可视区域
|
|
108
|
+
* @param menu 菜单元素
|
|
109
|
+
*/
|
|
110
|
+
protected adjustMenuPosition(menu: HTMLElement): void;
|
|
111
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { LayersPanelStyleConfig } from '../../../../core/types';
|
|
2
|
+
import { ToolbarButton } from '../../../../components/ToolbarButton';
|
|
3
|
+
import { BaseMenu } from '../menus/BaseMenu';
|
|
4
|
+
export interface MapTypeConfig {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
nameKey?: string;
|
|
8
|
+
thumbnail?: string;
|
|
9
|
+
placeNameLabel?: string;
|
|
10
|
+
placeNameLabelKey?: string;
|
|
11
|
+
forcePlaceName?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface LayersButtonHandlerOptions {
|
|
14
|
+
layersService?: any;
|
|
15
|
+
mapTypes?: MapTypeConfig[];
|
|
16
|
+
currentMapType?: string;
|
|
17
|
+
isPlaceNameChecked?: boolean;
|
|
18
|
+
token?: string;
|
|
19
|
+
isNoFlyZoneChecked?: boolean;
|
|
20
|
+
onMapTypeChange?: (mapTypeId: string) => void;
|
|
21
|
+
onPlaceNameToggle?: (isChecked: boolean) => void;
|
|
22
|
+
onShowNoFlyZones?: () => Promise<void>;
|
|
23
|
+
onNoFlyZoneToggle?: (isChecked: boolean) => void;
|
|
24
|
+
panelStyle?: LayersPanelStyleConfig;
|
|
25
|
+
}
|
|
26
|
+
export declare class LayersButtonHandler extends BaseMenu {
|
|
27
|
+
readonly id = "layers";
|
|
28
|
+
private options;
|
|
29
|
+
private button;
|
|
30
|
+
private panelStyle;
|
|
31
|
+
constructor(toolbarElement: HTMLElement, options?: LayersButtonHandlerOptions, i18n?: any, useI18n?: boolean);
|
|
32
|
+
show(anchor: HTMLElement): void;
|
|
33
|
+
initialize(button: ToolbarButton): void;
|
|
34
|
+
handleClick(): void;
|
|
35
|
+
handleMouseEnter(): void;
|
|
36
|
+
handleMouseLeave(): void;
|
|
37
|
+
destroy(): void;
|
|
38
|
+
updateOptions(options: Partial<LayersButtonHandlerOptions>): void;
|
|
39
|
+
private createSection;
|
|
40
|
+
private createMapTypeItem;
|
|
41
|
+
private createPlaceNameToggle;
|
|
42
|
+
private createNoFlyZoneItem;
|
|
43
|
+
private selectMapType;
|
|
44
|
+
private toggleNoFlyZone;
|
|
45
|
+
private togglePlaceName;
|
|
46
|
+
private getPanelStyles;
|
|
47
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { BaseButtonHandler } from './BaseButtonHandler';
|
|
2
|
+
import { ToolbarButton } from '../../../../components/ToolbarButton';
|
|
3
|
+
import { MeasurementServiceLike } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* 测量按钮处理器配置
|
|
6
|
+
*/
|
|
7
|
+
export interface MeasureButtonHandlerOptions {
|
|
8
|
+
/** 测量服务实例 */
|
|
9
|
+
measurementService?: MeasurementServiceLike;
|
|
10
|
+
/** 绘图助手实例 */
|
|
11
|
+
drawHelper?: any;
|
|
12
|
+
/** 测距开始回调 */
|
|
13
|
+
onDistanceStart?: () => void;
|
|
14
|
+
/** 测距绘制选项 */
|
|
15
|
+
getDistanceDrawOptions?: () => any;
|
|
16
|
+
/** 测面积开始回调 */
|
|
17
|
+
onAreaStart?: () => void;
|
|
18
|
+
/** 测面积绘制选项 */
|
|
19
|
+
getAreaDrawOptions?: () => any;
|
|
20
|
+
/** 测距完成回调 */
|
|
21
|
+
onDistanceComplete?: (positions: any[], distance: number) => void;
|
|
22
|
+
/** 测面积完成回调 */
|
|
23
|
+
onAreaComplete?: (positions: any[], area: number) => void;
|
|
24
|
+
/** 清除测量回调 */
|
|
25
|
+
onClear?: () => void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 测量按钮处理器类
|
|
29
|
+
*/
|
|
30
|
+
export declare class MeasureButtonHandler extends BaseButtonHandler {
|
|
31
|
+
readonly id = "measure";
|
|
32
|
+
private menu;
|
|
33
|
+
private options;
|
|
34
|
+
private activeMeasurementMode;
|
|
35
|
+
private boundMeasurementService;
|
|
36
|
+
private boundDrawHelper;
|
|
37
|
+
/**
|
|
38
|
+
* 构造函数
|
|
39
|
+
* @param viewer Cesium Viewer 实例
|
|
40
|
+
* @param options 配置选项
|
|
41
|
+
* @param i18n 国际化实例
|
|
42
|
+
* @param useI18n 是否使用国际化
|
|
43
|
+
*/
|
|
44
|
+
constructor(viewer: any, options?: MeasureButtonHandlerOptions, i18n?: any, useI18n?: boolean);
|
|
45
|
+
updateOptions(options: Partial<MeasureButtonHandlerOptions>): void;
|
|
46
|
+
/**
|
|
47
|
+
* 初始化按钮
|
|
48
|
+
* @param button 按钮实例
|
|
49
|
+
*/
|
|
50
|
+
initialize(button: ToolbarButton): void;
|
|
51
|
+
/**
|
|
52
|
+
* 处理点击事件
|
|
53
|
+
*/
|
|
54
|
+
handleClick(): void;
|
|
55
|
+
/**
|
|
56
|
+
* 处理鼠标进入事件
|
|
57
|
+
*/
|
|
58
|
+
handleMouseEnter(): void;
|
|
59
|
+
/**
|
|
60
|
+
* 处理鼠标离开事件
|
|
61
|
+
*/
|
|
62
|
+
handleMouseLeave(): void;
|
|
63
|
+
/**
|
|
64
|
+
* 销毁处理器
|
|
65
|
+
*/
|
|
66
|
+
destroy(): void;
|
|
67
|
+
private bindMeasurementServiceCallbacks;
|
|
68
|
+
private bindDrawCallbacks;
|
|
69
|
+
private handleMeasurementComplete;
|
|
70
|
+
private handleClearComplete;
|
|
71
|
+
private handleLegacyMeasureComplete;
|
|
72
|
+
private handleDrawComplete;
|
|
73
|
+
/**
|
|
74
|
+
* 显示测量菜单
|
|
75
|
+
* @param anchor 锚点元素
|
|
76
|
+
*/
|
|
77
|
+
private showMenu;
|
|
78
|
+
/**
|
|
79
|
+
* 开始测距
|
|
80
|
+
*/
|
|
81
|
+
private startDistanceMeasurement;
|
|
82
|
+
/**
|
|
83
|
+
* 开始测面积
|
|
84
|
+
*/
|
|
85
|
+
private startAreaMeasurement;
|
|
86
|
+
/**
|
|
87
|
+
* 清除测量
|
|
88
|
+
*/
|
|
89
|
+
private clearMeasurements;
|
|
90
|
+
/**
|
|
91
|
+
* 隐藏菜单
|
|
92
|
+
*/
|
|
93
|
+
hideMenu(): void;
|
|
94
|
+
}
|