@xingm/vmap-cesium-toolbar 0.0.1 → 0.0.2-alpha.10
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/dist/hooks/toolBarConfig.d.ts +6 -3
- package/dist/hooks/useDrawHelper.d.ts +65 -0
- package/dist/hooks/useHeatmapHelper.d.ts +34 -0
- package/dist/hooks/useOverlayHelper.d.ts +212 -0
- package/dist/index.d.ts +664 -36
- package/dist/index.js +5078 -1840
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +215 -128
- package/dist/index.umd.js.map +1 -1
- package/dist/libs/CesiumHeatmapLayer.d.ts +109 -0
- package/dist/libs/{CesiumMapHelper.d.ts → CesiumMapDraw.d.ts} +34 -51
- package/dist/libs/CesiumMapLoader.d.ts +11 -2
- package/dist/libs/CesiumMapModel.d.ts +5 -2
- package/dist/libs/CesiumMapToolbar.d.ts +23 -67
- package/dist/libs/CesiumOverlayService.d.ts +117 -0
- package/dist/libs/{CesiumMapConfig.d.ts → config/CesiumMapConfig.d.ts} +3 -3
- package/dist/libs/drawHelper/BaseDraw.d.ts +170 -0
- package/dist/libs/drawHelper/DrawCircle.d.ts +30 -0
- package/dist/libs/drawHelper/DrawLine.d.ts +44 -0
- package/dist/libs/drawHelper/DrawPolgon.d.ts +29 -0
- package/dist/libs/drawHelper/DrawRectangle.d.ts +24 -0
- package/dist/libs/drawHelper/index.d.ts +5 -0
- package/dist/libs/overlay/MapCircle.d.ts +64 -0
- package/dist/libs/overlay/MapIcon.d.ts +59 -0
- package/dist/libs/overlay/MapInfoWindow.d.ts +100 -0
- package/dist/libs/overlay/MapLabel.d.ts +63 -0
- package/dist/libs/overlay/MapMarker.d.ts +50 -0
- package/dist/libs/overlay/MapPolygon.d.ts +70 -0
- package/dist/libs/overlay/MapPolyline.d.ts +50 -0
- package/dist/libs/overlay/MapRectangle.d.ts +56 -0
- package/dist/libs/overlay/MapRing.d.ts +95 -0
- package/dist/libs/overlay/MapSVG.d.ts +63 -0
- package/dist/libs/overlay/index.d.ts +22 -0
- package/dist/libs/overlay/types.d.ts +41 -0
- package/dist/libs/toolBar/CesiumMapController.d.ts +78 -0
- package/dist/libs/toolBar/MapLayersService.d.ts +67 -0
- package/dist/libs/toolBar/MapSearchService.d.ts +41 -0
- package/dist/libs/toolBar/MapToolBarConfig.d.ts +3 -0
- package/dist/libs/toolBar/MeasurementService.d.ts +16 -0
- package/dist/libs/toolBar/NotFlyZonesService.d.ts +46 -0
- package/dist/package.json +5 -5
- package/dist/utils/calc.d.ts +44 -0
- package/dist/utils/common.d.ts +1 -0
- package/dist/z.const.d.ts +24 -0
- package/package.json +7 -7
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { Viewer, Entity, Cartesian3 } from '../../../node_modules/cesium';
|
|
2
|
+
import * as Cesium from "cesium";
|
|
3
|
+
/**
|
|
4
|
+
* 绘制结果接口
|
|
5
|
+
*/
|
|
6
|
+
export interface DrawResult {
|
|
7
|
+
entity: Entity | null;
|
|
8
|
+
type: "line" | "polygon" | "rectangle" | "circle";
|
|
9
|
+
positions: Cartesian3[];
|
|
10
|
+
distance?: number;
|
|
11
|
+
areaKm2?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 绘制回调接口
|
|
15
|
+
*/
|
|
16
|
+
export interface DrawCallbacks {
|
|
17
|
+
onDrawStart?: () => void;
|
|
18
|
+
onDrawEnd?: (entity: Entity | null, result: DrawResult) => void;
|
|
19
|
+
onEntityRemoved?: (entity: Entity) => void;
|
|
20
|
+
onMeasureComplete?: (result: DrawResult) => void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 扩展后的绘制实体类型
|
|
24
|
+
* 用于在 Entity 上挂载绘图相关的元数据
|
|
25
|
+
*/
|
|
26
|
+
export type DrawEntity = Entity & {
|
|
27
|
+
_drawType?: "line" | "polygon" | "rectangle" | "circle";
|
|
28
|
+
_drawOptions?: DrawOptions;
|
|
29
|
+
_groundPositions?: Cartesian3[];
|
|
30
|
+
_groundPosition?: Cartesian3;
|
|
31
|
+
_groundRectangle?: Cesium.Rectangle;
|
|
32
|
+
_radius?: number;
|
|
33
|
+
_borderEntity?: Entity;
|
|
34
|
+
_onClick?: (entity: Entity, ...args: any[]) => void;
|
|
35
|
+
_isSelected?: boolean;
|
|
36
|
+
_originalStyle?: {
|
|
37
|
+
material?: any;
|
|
38
|
+
width?: any;
|
|
39
|
+
outlineColor?: any;
|
|
40
|
+
outlineWidth?: any;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* 绘制时可选的样式和事件回调
|
|
45
|
+
*/
|
|
46
|
+
export interface DrawOptions {
|
|
47
|
+
strokeColor?: Cesium.Color | string;
|
|
48
|
+
strokeWidth?: number;
|
|
49
|
+
fillColor?: Cesium.Color | string;
|
|
50
|
+
outlineColor?: Cesium.Color | string;
|
|
51
|
+
outlineWidth?: number;
|
|
52
|
+
selected?: {
|
|
53
|
+
color?: Cesium.Color | string;
|
|
54
|
+
width?: number;
|
|
55
|
+
outlineColor?: Cesium.Color | string;
|
|
56
|
+
outlineWidth?: number;
|
|
57
|
+
};
|
|
58
|
+
onClick?: (entity: Entity, type?: "line" | "polygon" | "rectangle" | "circle", positions?: Cartesian3[]) => void;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 基础绘制类
|
|
62
|
+
* 包含所有绘制类型的通用逻辑
|
|
63
|
+
*/
|
|
64
|
+
export declare abstract class BaseDraw {
|
|
65
|
+
protected viewer: Viewer;
|
|
66
|
+
protected scene: Cesium.Scene;
|
|
67
|
+
protected entities: Cesium.EntityCollection;
|
|
68
|
+
protected offsetHeight: number;
|
|
69
|
+
protected originalDepthTestAgainstTerrain: boolean | null;
|
|
70
|
+
/**
|
|
71
|
+
* 当场景启用了 requestRenderMode(手动渲染)时,绘制过程中需要关闭该模式以保证动画和交互正常。
|
|
72
|
+
* 在绘制结束或取消时应恢复为原始值。
|
|
73
|
+
*/
|
|
74
|
+
protected originalRequestRenderMode: boolean | null;
|
|
75
|
+
protected callbacks: DrawCallbacks;
|
|
76
|
+
protected tempPositions: Cesium.Cartesian3[];
|
|
77
|
+
protected tempEntities: Cesium.Entity[];
|
|
78
|
+
protected tempLabelEntities: Cesium.Entity[];
|
|
79
|
+
protected finishedPointEntities: Cesium.Entity[];
|
|
80
|
+
/** 当前绘制的选项(如果有) */
|
|
81
|
+
protected drawOptions?: DrawOptions;
|
|
82
|
+
/**
|
|
83
|
+
* 公开只读访问当前临时数据,供调度器使用
|
|
84
|
+
*/
|
|
85
|
+
getTempPositions(): Cartesian3[];
|
|
86
|
+
getTempEntities(): Entity[];
|
|
87
|
+
getTempLabelEntities(): Entity[];
|
|
88
|
+
getFinishedPointEntities(): Entity[];
|
|
89
|
+
/**
|
|
90
|
+
* 允许调度器安全地重建临时数据
|
|
91
|
+
*/
|
|
92
|
+
setTempPositions(positions: Cartesian3[]): void;
|
|
93
|
+
setTempEntities(entities: Entity[]): void;
|
|
94
|
+
setTempLabelEntities(entities: Entity[]): void;
|
|
95
|
+
/**
|
|
96
|
+
* 供调度器调用的公开包装方法
|
|
97
|
+
*/
|
|
98
|
+
addPointForHelper(position: Cartesian3): void;
|
|
99
|
+
clearTempEntitiesForHelper(): void;
|
|
100
|
+
/**
|
|
101
|
+
* 清除当前绘制过程中的临时点实体
|
|
102
|
+
* 仅删除带有 point 组件的临时实体,保留其它临时线/面实体
|
|
103
|
+
*/
|
|
104
|
+
clearTempPointEntitiesForHelper(): void;
|
|
105
|
+
/**
|
|
106
|
+
* 删除最后一个点并根据剩余点重建预览实体
|
|
107
|
+
* 供调度器在右键删除点时调用,具体重建逻辑仍由各子类的 updateDrawingEntity 实现
|
|
108
|
+
*/
|
|
109
|
+
removeLastPointAndRedraw(): void;
|
|
110
|
+
/**
|
|
111
|
+
* 将任意颜色输入解析为 Cesium.Color
|
|
112
|
+
*/
|
|
113
|
+
protected resolveColor(input?: Cesium.Color | string): Cesium.Color;
|
|
114
|
+
/**
|
|
115
|
+
* 应用/切换选中样式(统一逻辑,供调度器和子类共用)
|
|
116
|
+
*/
|
|
117
|
+
protected applySelectedStyleToEntity(entity: Entity): void;
|
|
118
|
+
/**
|
|
119
|
+
* 恢复原始样式(兼容旧接口,内部仍走统一逻辑)
|
|
120
|
+
*/
|
|
121
|
+
protected restoreOriginalStyleForEntity(entity: Entity): void;
|
|
122
|
+
abstract updateDrawingEntity(previewPoint?: Cesium.Cartesian3): void;
|
|
123
|
+
abstract startDrawing(options?: DrawOptions): void;
|
|
124
|
+
/**
|
|
125
|
+
* 抽象方法:完成绘制
|
|
126
|
+
*/
|
|
127
|
+
abstract finishDrawing(): DrawResult | null;
|
|
128
|
+
/**
|
|
129
|
+
* 抽象方法:获取绘制类型
|
|
130
|
+
*/
|
|
131
|
+
abstract getDrawType(): "line" | "polygon" | "rectangle" | "circle";
|
|
132
|
+
constructor(viewer: Viewer, callbacks?: DrawCallbacks);
|
|
133
|
+
/**
|
|
134
|
+
* 根据场景模式更新偏移高度
|
|
135
|
+
*/
|
|
136
|
+
protected updateOffsetHeight(): void;
|
|
137
|
+
/**
|
|
138
|
+
* 拾取地形或椭球体上的位置
|
|
139
|
+
*/
|
|
140
|
+
protected pickGlobePosition(windowPosition: Cesium.Cartesian2): Cesium.Cartesian3 | null;
|
|
141
|
+
/**
|
|
142
|
+
* 如果场景启用了 requestRenderMode(手动渲染),在开始绘制时临时关闭以保证动画/交互正常。
|
|
143
|
+
*/
|
|
144
|
+
protected enableContinuousRenderingIfNeeded(): void;
|
|
145
|
+
/**
|
|
146
|
+
* 在绘制完成或取消时恢复 requestRenderMode 到原始状态(如果曾被修改过)。
|
|
147
|
+
*/
|
|
148
|
+
protected restoreRequestRenderModeIfNeeded(): void;
|
|
149
|
+
/**
|
|
150
|
+
* 添加一个点到临时位置数组并创建点实体
|
|
151
|
+
*/
|
|
152
|
+
protected addPoint(position: Cesium.Cartesian3): void;
|
|
153
|
+
/**
|
|
154
|
+
* 创建总长/面积标签图片
|
|
155
|
+
*/
|
|
156
|
+
protected createTotalLengthBillboardImage(text: string): HTMLCanvasElement;
|
|
157
|
+
/**
|
|
158
|
+
* 创建分段长度标签图片
|
|
159
|
+
*/
|
|
160
|
+
protected createSegmentLengthBillboardImage(text: string): HTMLCanvasElement;
|
|
161
|
+
/**
|
|
162
|
+
* 清理临时实体
|
|
163
|
+
*/
|
|
164
|
+
protected clearTempEntities(): void;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* 静态工具方法:切换实体的选中样式
|
|
168
|
+
* 用于避免在多个模块中重复实现相同逻辑
|
|
169
|
+
*/
|
|
170
|
+
export declare function toggleSelectedStyle(entity: DrawEntity): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Cartesian3 } from '../../../node_modules/cesium';
|
|
2
|
+
import { BaseDraw, DrawResult, DrawOptions } from './BaseDraw';
|
|
3
|
+
/**
|
|
4
|
+
* 画圆绘制类
|
|
5
|
+
*/
|
|
6
|
+
export declare class DrawCircle extends BaseDraw {
|
|
7
|
+
private currentCircleEntity;
|
|
8
|
+
private currentBorderEntity;
|
|
9
|
+
private centerPosition;
|
|
10
|
+
/**
|
|
11
|
+
* 开始绘制
|
|
12
|
+
*/
|
|
13
|
+
startDrawing(options?: DrawOptions): void;
|
|
14
|
+
/**
|
|
15
|
+
* 更新绘制实体(预览)
|
|
16
|
+
*/
|
|
17
|
+
updateDrawingEntity(previewPoint?: Cartesian3): void;
|
|
18
|
+
/**
|
|
19
|
+
* 完成绘制
|
|
20
|
+
*/
|
|
21
|
+
finishDrawing(): DrawResult | null;
|
|
22
|
+
/**
|
|
23
|
+
* 获取绘制类型
|
|
24
|
+
*/
|
|
25
|
+
getDrawType(): "line" | "polygon" | "rectangle" | "circle";
|
|
26
|
+
/**
|
|
27
|
+
* 生成近似圆(多边形)顶点
|
|
28
|
+
*/
|
|
29
|
+
private generateCirclePositions;
|
|
30
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Cartesian3 } from '../../../node_modules/cesium';
|
|
2
|
+
import { BaseDraw, DrawResult, DrawOptions } from './BaseDraw';
|
|
3
|
+
/**
|
|
4
|
+
* 画线绘制类
|
|
5
|
+
*/
|
|
6
|
+
export declare class DrawLine extends BaseDraw {
|
|
7
|
+
private currentLineEntity;
|
|
8
|
+
private currentSegmentLabels;
|
|
9
|
+
private currentTotalLabel;
|
|
10
|
+
private currentLinePositions;
|
|
11
|
+
private isTotalLabelWarmedUp;
|
|
12
|
+
/**
|
|
13
|
+
* 开始绘制
|
|
14
|
+
*/
|
|
15
|
+
startDrawing(options?: DrawOptions): void;
|
|
16
|
+
/**
|
|
17
|
+
* 更新绘制实体(预览)
|
|
18
|
+
*/
|
|
19
|
+
updateDrawingEntity(previewPoint?: Cartesian3): void;
|
|
20
|
+
/**
|
|
21
|
+
* 完成绘制
|
|
22
|
+
*/
|
|
23
|
+
finishDrawing(): DrawResult | null;
|
|
24
|
+
/**
|
|
25
|
+
* 获取绘制类型
|
|
26
|
+
*/
|
|
27
|
+
getDrawType(): "line" | "polygon" | "rectangle" | "circle";
|
|
28
|
+
/**
|
|
29
|
+
* 清理线条实体
|
|
30
|
+
*/
|
|
31
|
+
private clearLineEntity;
|
|
32
|
+
/**
|
|
33
|
+
* 更新分段标签
|
|
34
|
+
*/
|
|
35
|
+
private updateSegmentLabels;
|
|
36
|
+
/**
|
|
37
|
+
* 更新总距离标签
|
|
38
|
+
*/
|
|
39
|
+
private updateTotalLabel;
|
|
40
|
+
/**
|
|
41
|
+
* 总长标签预热
|
|
42
|
+
*/
|
|
43
|
+
private warmupTotalLengthLabel;
|
|
44
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Cartesian3 } from '../../../node_modules/cesium';
|
|
2
|
+
import { BaseDraw, DrawResult, DrawOptions } from './BaseDraw';
|
|
3
|
+
/**
|
|
4
|
+
* 画多边形绘制类
|
|
5
|
+
*/
|
|
6
|
+
export declare class DrawPolygon extends BaseDraw {
|
|
7
|
+
private currentPolygonEntity;
|
|
8
|
+
private currentBorderEntity;
|
|
9
|
+
/**
|
|
10
|
+
* 开始绘制
|
|
11
|
+
*/
|
|
12
|
+
startDrawing(options?: DrawOptions): void;
|
|
13
|
+
/**
|
|
14
|
+
* 更新绘制实体(预览)
|
|
15
|
+
*/
|
|
16
|
+
updateDrawingEntity(previewPoint?: Cartesian3): void;
|
|
17
|
+
/**
|
|
18
|
+
* 完成绘制
|
|
19
|
+
*/
|
|
20
|
+
finishDrawing(): DrawResult | null;
|
|
21
|
+
/**
|
|
22
|
+
* 清理所有绘制相关的实体
|
|
23
|
+
*/
|
|
24
|
+
clear(): void;
|
|
25
|
+
/**
|
|
26
|
+
* 获取绘制类型
|
|
27
|
+
*/
|
|
28
|
+
getDrawType(): "line" | "polygon" | "rectangle" | "circle";
|
|
29
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Cartesian3 } from '../../../node_modules/cesium';
|
|
2
|
+
import { BaseDraw, DrawResult, DrawOptions } from './BaseDraw';
|
|
3
|
+
/**
|
|
4
|
+
* 画矩形绘制类
|
|
5
|
+
*/
|
|
6
|
+
export declare class DrawRectangle extends BaseDraw {
|
|
7
|
+
private currentRectangleEntity;
|
|
8
|
+
/**
|
|
9
|
+
* 开始绘制
|
|
10
|
+
*/
|
|
11
|
+
startDrawing(options?: DrawOptions): void;
|
|
12
|
+
/**
|
|
13
|
+
* 更新绘制实体(预览)
|
|
14
|
+
*/
|
|
15
|
+
updateDrawingEntity(previewPoint?: Cartesian3): void;
|
|
16
|
+
/**
|
|
17
|
+
* 完成绘制
|
|
18
|
+
*/
|
|
19
|
+
finishDrawing(): DrawResult | null;
|
|
20
|
+
/**
|
|
21
|
+
* 获取绘制类型
|
|
22
|
+
*/
|
|
23
|
+
getDrawType(): "line" | "polygon" | "rectangle" | "circle";
|
|
24
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { BaseDraw, type DrawResult, type DrawCallbacks, type DrawOptions, type DrawEntity, toggleSelectedStyle } from './BaseDraw';
|
|
2
|
+
export { DrawLine } from './DrawLine';
|
|
3
|
+
export { DrawPolygon } from './DrawPolgon';
|
|
4
|
+
export { DrawRectangle } from './DrawRectangle';
|
|
5
|
+
export { DrawCircle } from './DrawCircle';
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Viewer, Entity, Color, HeightReference } from '../../../node_modules/cesium';
|
|
2
|
+
import { OverlayPosition } from './types';
|
|
3
|
+
import * as Cesium from "cesium";
|
|
4
|
+
/**
|
|
5
|
+
* Circle 选项
|
|
6
|
+
*/
|
|
7
|
+
export interface CircleOptions {
|
|
8
|
+
position: OverlayPosition;
|
|
9
|
+
radius: number;
|
|
10
|
+
material?: Cesium.MaterialProperty | Color | string;
|
|
11
|
+
outline?: boolean;
|
|
12
|
+
outlineColor?: Color | string;
|
|
13
|
+
outlineWidth?: number;
|
|
14
|
+
heightReference?: HeightReference;
|
|
15
|
+
extrudedHeight?: number;
|
|
16
|
+
heightEpsilon?: number;
|
|
17
|
+
onClick?: (entity: Entity) => void;
|
|
18
|
+
id?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Circle 工具类
|
|
22
|
+
*/
|
|
23
|
+
export declare class MapCircle {
|
|
24
|
+
private viewer;
|
|
25
|
+
private entities;
|
|
26
|
+
constructor(viewer: Viewer);
|
|
27
|
+
/**
|
|
28
|
+
* 转换位置为 Cartesian3
|
|
29
|
+
*/
|
|
30
|
+
private convertPosition;
|
|
31
|
+
/**
|
|
32
|
+
* 转换颜色
|
|
33
|
+
*/
|
|
34
|
+
private resolveColor;
|
|
35
|
+
/**
|
|
36
|
+
* 解析材质
|
|
37
|
+
*/
|
|
38
|
+
private resolveMaterial;
|
|
39
|
+
/**
|
|
40
|
+
* 添加 Circle(圆形)
|
|
41
|
+
*/
|
|
42
|
+
add(options: CircleOptions): Entity;
|
|
43
|
+
/**
|
|
44
|
+
* 生成近似圆(多边形)顶点,返回 Cartesian3 数组。
|
|
45
|
+
* 使用大圆航线公式,segments 越大越平滑。
|
|
46
|
+
*/
|
|
47
|
+
private generateCirclePositions;
|
|
48
|
+
/**
|
|
49
|
+
* 更新 Circle 位置
|
|
50
|
+
*/
|
|
51
|
+
updatePosition(entity: Entity, position: OverlayPosition): void;
|
|
52
|
+
/**
|
|
53
|
+
* 更新 Circle 半径
|
|
54
|
+
*/
|
|
55
|
+
updateRadius(entity: Entity, radius: number): void;
|
|
56
|
+
/**
|
|
57
|
+
* 更新 Circle 样式
|
|
58
|
+
*/
|
|
59
|
+
updateStyle(entity: Entity, options: Partial<Pick<CircleOptions, 'material' | 'outline' | 'outlineColor' | 'outlineWidth'>>): void;
|
|
60
|
+
/**
|
|
61
|
+
* 移除 Circle(通过实体或实体 id)
|
|
62
|
+
*/
|
|
63
|
+
remove(entityOrId: Entity | string): boolean;
|
|
64
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Viewer, Entity, Color, HeightReference, VerticalOrigin, HorizontalOrigin } from '../../../node_modules/cesium';
|
|
2
|
+
import { OverlayPosition } from './types';
|
|
3
|
+
import * as Cesium from "cesium";
|
|
4
|
+
/**
|
|
5
|
+
* Icon 选项
|
|
6
|
+
*/
|
|
7
|
+
export interface IconOptions {
|
|
8
|
+
position: OverlayPosition;
|
|
9
|
+
image: string;
|
|
10
|
+
width?: number;
|
|
11
|
+
height?: number;
|
|
12
|
+
scale?: number;
|
|
13
|
+
rotation?: number;
|
|
14
|
+
pixelOffset?: Cesium.Cartesian2;
|
|
15
|
+
eyeOffset?: Cesium.Cartesian3;
|
|
16
|
+
horizontalOrigin?: HorizontalOrigin;
|
|
17
|
+
verticalOrigin?: VerticalOrigin;
|
|
18
|
+
heightReference?: HeightReference;
|
|
19
|
+
disableDepthTestDistance?: number;
|
|
20
|
+
color?: Color | string;
|
|
21
|
+
onClick?: (entity: Entity) => void;
|
|
22
|
+
id?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Icon 工具类
|
|
26
|
+
*/
|
|
27
|
+
export declare class MapIcon {
|
|
28
|
+
private viewer;
|
|
29
|
+
private entities;
|
|
30
|
+
constructor(viewer: Viewer);
|
|
31
|
+
/**
|
|
32
|
+
* 转换位置为 Cartesian3
|
|
33
|
+
*/
|
|
34
|
+
private convertPosition;
|
|
35
|
+
/**
|
|
36
|
+
* 转换颜色
|
|
37
|
+
*/
|
|
38
|
+
private resolveColor;
|
|
39
|
+
/**
|
|
40
|
+
* 添加 Icon(图标,使用 Billboard)
|
|
41
|
+
*/
|
|
42
|
+
add(options: IconOptions): Entity;
|
|
43
|
+
/**
|
|
44
|
+
* 更新 Icon 位置
|
|
45
|
+
*/
|
|
46
|
+
updatePosition(entity: Entity, position: OverlayPosition): void;
|
|
47
|
+
/**
|
|
48
|
+
* 更新 Icon 图片
|
|
49
|
+
*/
|
|
50
|
+
updateImage(entity: Entity, image: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* 更新 Icon 样式
|
|
53
|
+
*/
|
|
54
|
+
updateStyle(entity: Entity, options: Partial<Pick<IconOptions, 'scale' | 'rotation' | 'color'>>): void;
|
|
55
|
+
/**
|
|
56
|
+
* 移除 Icon(通过实体或实体 id)
|
|
57
|
+
*/
|
|
58
|
+
remove(entityOrId: Entity | string): boolean;
|
|
59
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Viewer, Entity } from '../../../node_modules/cesium';
|
|
2
|
+
import { OverlayPosition } from './types';
|
|
3
|
+
import * as Cesium from 'cesium';
|
|
4
|
+
export interface InfoWindowOptions {
|
|
5
|
+
position: OverlayPosition;
|
|
6
|
+
content: string | HTMLElement;
|
|
7
|
+
width?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
pixelOffset?: Cesium.Cartesian2;
|
|
10
|
+
show?: boolean;
|
|
11
|
+
onClick?: (entity: Entity) => void;
|
|
12
|
+
id?: string;
|
|
13
|
+
closable?: boolean;
|
|
14
|
+
onClose?: (entity: Entity) => void;
|
|
15
|
+
backgroundColor?: string;
|
|
16
|
+
color?: string;
|
|
17
|
+
font?: string;
|
|
18
|
+
className?: string;
|
|
19
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
20
|
+
showArrow?: boolean;
|
|
21
|
+
arrowSize?: number;
|
|
22
|
+
positionOffset?: 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'left-top' | 'left-bottom' | 'right-top' | 'right-bottom';
|
|
23
|
+
hideWhenOutOfView?: boolean;
|
|
24
|
+
anchorHeight?: number;
|
|
25
|
+
anchorPixel?: number;
|
|
26
|
+
tailGap?: number;
|
|
27
|
+
updateInterval?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 面向 Cesium 的 HTML 信息窗口管理器
|
|
31
|
+
* 要求 container 为 position: relative 的 DOM 容器(通常与 viewer.canvas 同级或包裹)
|
|
32
|
+
*/
|
|
33
|
+
export declare class MapInfoWindow {
|
|
34
|
+
private viewer;
|
|
35
|
+
private container;
|
|
36
|
+
private entityMap;
|
|
37
|
+
private currentTopZIndex;
|
|
38
|
+
private defaultUpdateInterval;
|
|
39
|
+
private isCameraMoving;
|
|
40
|
+
private cameraMoveStartListener?;
|
|
41
|
+
private cameraMoveEndListener?;
|
|
42
|
+
/**
|
|
43
|
+
* 合并用户传入的 InfoWindowOptions 与默认值,提升入参灵活性。
|
|
44
|
+
* 注意:必填项 position / content 由调用方提供,不在默认值内。
|
|
45
|
+
*/
|
|
46
|
+
private mergeOptions;
|
|
47
|
+
constructor(viewer: Viewer, container: HTMLElement);
|
|
48
|
+
/**
|
|
49
|
+
* Set default update interval (ms) for position updates when an InfoWindow doesn't specify `updateInterval`.
|
|
50
|
+
* 0 means update every frame.
|
|
51
|
+
*/
|
|
52
|
+
setDefaultUpdateInterval(ms: number): void;
|
|
53
|
+
/**
|
|
54
|
+
* Force immediate update (recompute positions) of all managed info windows.
|
|
55
|
+
*/
|
|
56
|
+
forceUpdateAll(): void;
|
|
57
|
+
private convertPosition;
|
|
58
|
+
/**
|
|
59
|
+
* 将世界坐标转换为相对于 container 的 CSS 像素坐标
|
|
60
|
+
*/
|
|
61
|
+
private getContainerPixelPosition;
|
|
62
|
+
/**
|
|
63
|
+
* 更新单个 infoWindow 的显示状态和位置
|
|
64
|
+
*/
|
|
65
|
+
private updateDomPosition;
|
|
66
|
+
/**
|
|
67
|
+
* 创建 DOM 元素
|
|
68
|
+
*/
|
|
69
|
+
private createDomElement;
|
|
70
|
+
/**
|
|
71
|
+
* 将指定 InfoWindow 置于最前
|
|
72
|
+
*/
|
|
73
|
+
bringToFront(entity: Entity): void;
|
|
74
|
+
/**
|
|
75
|
+
* 添加信息窗口
|
|
76
|
+
*/
|
|
77
|
+
add(options: InfoWindowOptions): Entity;
|
|
78
|
+
/**
|
|
79
|
+
* 更新位置
|
|
80
|
+
*/
|
|
81
|
+
updatePosition(entity: Entity, position: OverlayPosition): void;
|
|
82
|
+
/**
|
|
83
|
+
* 更新内容
|
|
84
|
+
*/
|
|
85
|
+
updateContent(entity: Entity, content: string | HTMLElement): void;
|
|
86
|
+
/**
|
|
87
|
+
* 显示/隐藏
|
|
88
|
+
*/
|
|
89
|
+
setVisible(entity: Entity, visible: boolean): void;
|
|
90
|
+
show(entity: Entity): void;
|
|
91
|
+
hide(entity: Entity): void;
|
|
92
|
+
/**
|
|
93
|
+
* 移除信息窗口(清理 DOM + 监听器 + 实体)
|
|
94
|
+
*/
|
|
95
|
+
remove(entity: Entity): void;
|
|
96
|
+
/**
|
|
97
|
+
* 销毁整个管理器(清理所有 infoWindow)
|
|
98
|
+
*/
|
|
99
|
+
destroy(): void;
|
|
100
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Viewer, Entity, Color, HeightReference, LabelStyle, VerticalOrigin, HorizontalOrigin } from '../../../node_modules/cesium';
|
|
2
|
+
import { OverlayPosition } from './types';
|
|
3
|
+
import * as Cesium from "cesium";
|
|
4
|
+
/**
|
|
5
|
+
* Label 选项
|
|
6
|
+
*/
|
|
7
|
+
export interface LabelOptions {
|
|
8
|
+
position: OverlayPosition;
|
|
9
|
+
text: string;
|
|
10
|
+
font?: string;
|
|
11
|
+
fillColor?: Color | string;
|
|
12
|
+
outlineColor?: Color | string;
|
|
13
|
+
outlineWidth?: number;
|
|
14
|
+
style?: LabelStyle;
|
|
15
|
+
pixelOffset?: Cesium.Cartesian2;
|
|
16
|
+
eyeOffset?: Cesium.Cartesian3;
|
|
17
|
+
horizontalOrigin?: HorizontalOrigin;
|
|
18
|
+
verticalOrigin?: VerticalOrigin;
|
|
19
|
+
heightReference?: HeightReference;
|
|
20
|
+
scale?: number;
|
|
21
|
+
showBackground?: boolean;
|
|
22
|
+
backgroundColor?: Color | string;
|
|
23
|
+
backgroundPadding?: Cesium.Cartesian2;
|
|
24
|
+
disableDepthTestDistance?: number;
|
|
25
|
+
onClick?: (entity: Entity) => void;
|
|
26
|
+
id?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Label 工具类
|
|
30
|
+
*/
|
|
31
|
+
export declare class MapLabel {
|
|
32
|
+
private viewer;
|
|
33
|
+
private entities;
|
|
34
|
+
constructor(viewer: Viewer);
|
|
35
|
+
/**
|
|
36
|
+
* 转换位置为 Cartesian3
|
|
37
|
+
*/
|
|
38
|
+
private convertPosition;
|
|
39
|
+
/**
|
|
40
|
+
* 转换颜色
|
|
41
|
+
*/
|
|
42
|
+
private resolveColor;
|
|
43
|
+
/**
|
|
44
|
+
* 添加 Label(文本标签)
|
|
45
|
+
*/
|
|
46
|
+
add(options: LabelOptions): Entity;
|
|
47
|
+
/**
|
|
48
|
+
* 更新 Label 位置
|
|
49
|
+
*/
|
|
50
|
+
updatePosition(entity: Entity, position: OverlayPosition): void;
|
|
51
|
+
/**
|
|
52
|
+
* 更新 Label 文本
|
|
53
|
+
*/
|
|
54
|
+
updateText(entity: Entity, text: string): void;
|
|
55
|
+
/**
|
|
56
|
+
* 更新 Label 样式
|
|
57
|
+
*/
|
|
58
|
+
updateStyle(entity: Entity, options: Partial<Pick<LabelOptions, 'fillColor' | 'outlineColor' | 'outlineWidth' | 'font' | 'scale'>>): void;
|
|
59
|
+
/**
|
|
60
|
+
* 移除 Label(通过实体或实体 id)
|
|
61
|
+
*/
|
|
62
|
+
remove(entityOrId: Entity | string): boolean;
|
|
63
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Viewer, Entity, Color, HeightReference } from '../../../node_modules/cesium';
|
|
2
|
+
import { OverlayPosition } from './types';
|
|
3
|
+
import * as Cesium from "cesium";
|
|
4
|
+
/**
|
|
5
|
+
* Marker 选项
|
|
6
|
+
*/
|
|
7
|
+
export interface MarkerOptions {
|
|
8
|
+
position: OverlayPosition;
|
|
9
|
+
pixelSize?: number;
|
|
10
|
+
color?: Color | string;
|
|
11
|
+
outlineColor?: Color | string;
|
|
12
|
+
outlineWidth?: number;
|
|
13
|
+
heightReference?: HeightReference;
|
|
14
|
+
scaleByDistance?: Cesium.NearFarScalar;
|
|
15
|
+
disableDepthTestDistance?: number;
|
|
16
|
+
onClick?: (entity: Entity) => void;
|
|
17
|
+
id?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Marker 工具类
|
|
21
|
+
*/
|
|
22
|
+
export declare class MapMarker {
|
|
23
|
+
private viewer;
|
|
24
|
+
private entities;
|
|
25
|
+
constructor(viewer: Viewer);
|
|
26
|
+
/**
|
|
27
|
+
* 转换位置为 Cartesian3
|
|
28
|
+
*/
|
|
29
|
+
private convertPosition;
|
|
30
|
+
/**
|
|
31
|
+
* 转换颜色
|
|
32
|
+
*/
|
|
33
|
+
private resolveColor;
|
|
34
|
+
/**
|
|
35
|
+
* 添加 Marker(点标记)
|
|
36
|
+
*/
|
|
37
|
+
add(options: MarkerOptions): Entity;
|
|
38
|
+
/**
|
|
39
|
+
* 更新 Marker 位置
|
|
40
|
+
*/
|
|
41
|
+
updatePosition(entity: Entity, position: OverlayPosition): void;
|
|
42
|
+
/**
|
|
43
|
+
* 更新 Marker 样式
|
|
44
|
+
*/
|
|
45
|
+
updateStyle(entity: Entity, options: Partial<Pick<MarkerOptions, 'color' | 'outlineColor' | 'outlineWidth' | 'pixelSize'>>): void;
|
|
46
|
+
/**
|
|
47
|
+
* 移除 Marker(通过实体或实体 id)
|
|
48
|
+
*/
|
|
49
|
+
remove(entityOrId: Entity | string): boolean;
|
|
50
|
+
}
|