@yituengine/keymap 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.
Files changed (75) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +148 -0
  3. package/dist/engine.js +1 -0
  4. package/dist/types/core/Assets.d.ts +11 -0
  5. package/dist/types/core/Classification.d.ts +17 -0
  6. package/dist/types/core/Flatten.d.ts +74 -0
  7. package/dist/types/core/Status.d.ts +3 -0
  8. package/dist/types/core/pathAnim.d.ts +27 -0
  9. package/dist/types/core/transformFun.d.ts +16 -0
  10. package/dist/types/draw/baseDraw.d.ts +74 -0
  11. package/dist/types/draw/drawCircle.d.ts +44 -0
  12. package/dist/types/draw/drawPoint.d.ts +30 -0
  13. package/dist/types/draw/drawPolygon.d.ts +35 -0
  14. package/dist/types/draw/drawPolyline.d.ts +35 -0
  15. package/dist/types/draw/index.d.ts +17 -0
  16. package/dist/types/effect/cloud.d.ts +34 -0
  17. package/dist/types/effect/fog.d.ts +44 -0
  18. package/dist/types/effect/fogPro.d.ts +46 -0
  19. package/dist/types/effect/index.d.ts +32 -0
  20. package/dist/types/effect/lensflare.d.ts +38 -0
  21. package/dist/types/effect/rainy.d.ts +47 -0
  22. package/dist/types/effect/snowCover.d.ts +50 -0
  23. package/dist/types/effect/snowFall.d.ts +38 -0
  24. package/dist/types/event/index.d.ts +12 -0
  25. package/dist/types/event/menu.d.ts +110 -0
  26. package/dist/types/event/mousePick.d.ts +57 -0
  27. package/dist/types/graphic/baseGraphic.d.ts +131 -0
  28. package/dist/types/graphic/billboardGraphic.d.ts +75 -0
  29. package/dist/types/graphic/circleGraphic.d.ts +103 -0
  30. package/dist/types/graphic/customPopupGraphic.d.ts +75 -0
  31. package/dist/types/graphic/index.d.ts +32 -0
  32. package/dist/types/graphic/modelGraphic.d.ts +90 -0
  33. package/dist/types/graphic/polygonGraphic.d.ts +124 -0
  34. package/dist/types/graphic/polylineGraphic.d.ts +100 -0
  35. package/dist/types/graphic/popupGraphic.d.ts +85 -0
  36. package/dist/types/layer/graphicLayer.d.ts +96 -0
  37. package/dist/types/layer/heatmapLayer/heatmapRenderer.d.ts +39 -0
  38. package/dist/types/layer/heatmapLayer.d.ts +113 -0
  39. package/dist/types/layer/index.d.ts +14 -0
  40. package/dist/types/layer/tilesetLayer.d.ts +107 -0
  41. package/dist/types/main.d.ts +68 -0
  42. package/dist/types/map/defaultInteractions.d.ts +26 -0
  43. package/dist/types/map/index.d.ts +254 -0
  44. package/dist/types/material/LightingFlow.d.ts +63 -0
  45. package/dist/types/material/PolylineDashed.d.ts +68 -0
  46. package/dist/types/material/TextureFlow.d.ts +94 -0
  47. package/dist/types/material/Wave.d.ts +75 -0
  48. package/dist/types/material/index.d.ts +20 -0
  49. package/dist/types/measure/baseMeasure.d.ts +93 -0
  50. package/dist/types/measure/index.d.ts +18 -0
  51. package/dist/types/measure/measureArea.d.ts +46 -0
  52. package/dist/types/measure/measureCutFill.d.ts +69 -0
  53. package/dist/types/measure/measureDistance.d.ts +50 -0
  54. package/dist/types/measure/measureHeight.d.ts +47 -0
  55. package/dist/types/primitive/ClassificationPrimitive.d.ts +72 -0
  56. package/dist/types/primitive/Tube.d.ts +38 -0
  57. package/dist/types/primitive/Wall.d.ts +47 -0
  58. package/dist/types/primitive/basePrimitive.d.ts +42 -0
  59. package/dist/types/primitive/index.d.ts +16 -0
  60. package/dist/types/types/general.d.ts +94 -0
  61. package/dist/types/types/index.d.ts +2 -0
  62. package/dist/types/types/public.d.ts +11 -0
  63. package/dist/types/utils/CoordTransform.d.ts +26 -0
  64. package/dist/types/utils/controlPoint.d.ts +10 -0
  65. package/dist/types/utils/cutFillAnalysis.d.ts +38 -0
  66. package/dist/types/utils/graphic.d.ts +45 -0
  67. package/dist/types/utils/midPoint.d.ts +11 -0
  68. package/dist/types/utils/rightMenu.d.ts +1 -0
  69. package/dist/types/utils/tools.d.ts +38 -0
  70. package/docs/guide/draw-measure.md +97 -0
  71. package/docs/guide/graphic.md +136 -0
  72. package/docs/guide/index.md +29 -0
  73. package/docs/guide/menu.md +101 -0
  74. package/docs/guide/quick-start.md +74 -0
  75. package/package.json +58 -0
@@ -0,0 +1,32 @@
1
+ import ModelGraphic from './modelGraphic';
2
+ import PolylineGraphic from './polylineGraphic';
3
+ import PolygonGraphic from './polygonGraphic';
4
+ import CircleGraphic from './circleGraphic';
5
+ import BillboardGraphic from './billboardGraphic';
6
+ import PopupGraphic from './popupGraphic';
7
+ import CustomPopupGraphic from './customPopupGraphic';
8
+ export { default as ModelGraphic } from './modelGraphic';
9
+ export { default as PolylineGraphic } from './polylineGraphic';
10
+ export { default as PolygonGraphic } from './polygonGraphic';
11
+ export { default as CircleGraphic } from './circleGraphic';
12
+ export { default as BillboardGraphic } from './billboardGraphic';
13
+ export { default as CustomPopupGraphic } from './customPopupGraphic';
14
+ export { default as PopupGraphic } from './popupGraphic';
15
+ export type { BillboardGraphicOptions } from './billboardGraphic';
16
+ export type { CircleGraphicOptions } from './circleGraphic';
17
+ export type { CustomPopupGraphicOptions } from './customPopupGraphic';
18
+ export type { ModelGraphicOptions, ModelPathOptions } from './modelGraphic';
19
+ export type { PolygonGraphicOptions } from './polygonGraphic';
20
+ export type { PolylineGraphicOptions } from './polylineGraphic';
21
+ export type { PopupGraphicOptions } from './popupGraphic';
22
+ export type GraphicType = BillboardGraphic | ModelGraphic | PolylineGraphic | PolygonGraphic | CircleGraphic | PopupGraphic | CustomPopupGraphic;
23
+ declare const _default: {
24
+ BillboardGraphic: typeof BillboardGraphic;
25
+ ModelGraphic: typeof ModelGraphic;
26
+ PolylineGraphic: typeof PolylineGraphic;
27
+ PolygonGraphic: typeof PolygonGraphic;
28
+ CircleGraphic: typeof CircleGraphic;
29
+ PopupGraphic: typeof PopupGraphic;
30
+ CustomPopupGraphic: typeof CustomPopupGraphic;
31
+ };
32
+ export default _default;
@@ -0,0 +1,90 @@
1
+ import PathAnim from '../core/pathAnim';
2
+ import BaseGraphic, { BaseGraphicOptions } from './baseGraphic';
3
+ import { GraphicLayer } from '../layer';
4
+ import * as Cesium from 'cesium';
5
+ import { Rotation } from '../types';
6
+ /**
7
+ * 模型图形构造参数。
8
+ *
9
+ * 继承 Cesium `ModelGraphics` 参数,并追加模型初始姿态配置。
10
+ */
11
+ export interface ModelGraphicOptions extends Cesium.ModelGraphics.ConstructorOptions, BaseGraphicOptions {
12
+ /** 模型初始旋转角,单位为弧度。 */
13
+ rotation?: Rotation;
14
+ }
15
+ /** 模型路径动画配置。 */
16
+ export interface ModelPathOptions {
17
+ /** 路径点位数组。 */
18
+ positions: Cesium.Cartesian3[];
19
+ /** 路径运动时使用的模型姿态。 */
20
+ rotation?: Rotation;
21
+ /** 路径播放速度。 */
22
+ speed?: number;
23
+ /** 是否在路径播放时插值旋转。 */
24
+ isLerpRotation?: boolean;
25
+ /** 参与路径播放的模型 Entity;通常由 `setPath()` 自动注入。 */
26
+ model?: Cesium.Entity | null;
27
+ }
28
+ /**
29
+ * 三维模型图形。
30
+ *
31
+ * 用于把 Cesium `ModelGraphics` 添加到业务图层,支持移动、旋转、路径动画、导览视角和生成动画。
32
+ */
33
+ declare class ModelGraphic extends BaseGraphic {
34
+ /** 图形类型标识。 */
35
+ readonly type: 'ModelGraphic';
36
+ /** Cesium ModelGraphics 实例。 */
37
+ graphic: Cesium.ModelGraphics;
38
+ /** 当前模型路径动画实例。 */
39
+ pathAnim: PathAnim | null;
40
+ private rotation;
41
+ /**
42
+ * 创建模型图形。
43
+ *
44
+ * @param opt 模型图形配置。
45
+ */
46
+ constructor(opt: ModelGraphicOptions);
47
+ /**
48
+ * 将模型添加到图层。
49
+ *
50
+ * 添加后会创建或获取 Entity,挂载 `model`、标签、初始位置和初始旋转。
51
+ *
52
+ * @param layer 目标图层。
53
+ */
54
+ add(layer: GraphicLayer): void;
55
+ /** 销毁模型 Entity 和关联弹窗。 */
56
+ destroy(): void;
57
+ /** 将相机定位到模型 Entity。 */
58
+ zoomTo(): void;
59
+ /**
60
+ * 移动模型到新位置。
61
+ *
62
+ * @param position 新的 Cesium Cartesian3 位置。
63
+ */
64
+ moveTo(position: Cesium.Cartesian3): void;
65
+ /**
66
+ * 设置模型旋转。
67
+ *
68
+ * @param rotation heading、pitch、roll 旋转角,单位为弧度。
69
+ */
70
+ setRotation(rotation: Rotation): void;
71
+ /**
72
+ * 设置模型路径动画。
73
+ *
74
+ * @param opt 路径动画配置。
75
+ * @param isGuide 是否进入跟随导览视角。
76
+ */
77
+ setPath(opt: ModelPathOptions, isGuide?: boolean): void;
78
+ /** 进入模型跟随导览视角。 */
79
+ enterGuide(): void;
80
+ /** 退出模型跟随导览视角。 */
81
+ exitGuide(): void;
82
+ /** 导览模式下的相机姿态更新回调。 */
83
+ guideUpdate(): void;
84
+ /** 播放模型生成动画,通过裁剪面逐步展示模型。 */
85
+ animate(): void;
86
+ }
87
+ declare namespace ModelGraphic {
88
+ type ConstructorOptions = ModelGraphicOptions;
89
+ }
90
+ export default ModelGraphic;
@@ -0,0 +1,124 @@
1
+ import * as Cesium from 'cesium';
2
+ import BaseGraphic, { BaseGraphicOptions } from './baseGraphic';
3
+ import { GraphicLayer } from '../layer';
4
+ /**
5
+ * 多边形图形构造参数。
6
+ *
7
+ * 继承 Cesium `PolygonGraphics` 参数,并追加顶点数组、编辑回调和描边配置。
8
+ */
9
+ export interface PolygonGraphicOptions extends Cesium.PolygonGraphics.ConstructorOptions, BaseGraphicOptions {
10
+ /** 多边形顶点数组,按顺序组成闭合面。 */
11
+ positions: Cesium.Cartesian3[];
12
+ /** 多边形标签配置。 */
13
+ label?: Cesium.LabelGraphics.ConstructorOptions;
14
+ /** 顶点新增、移动、删除或整体更新后触发。 */
15
+ onChanged?: (positions: Cesium.Cartesian3[]) => void;
16
+ /** 常态描边宽度,传入 `0` 可关闭常态描边。 */
17
+ outlineWidth?: number;
18
+ /** 常态描边颜色,优先级低于 `outlineMaterial`。 */
19
+ outlineColor?: Cesium.Color;
20
+ /** 常态描边材质,优先级高于 `outlineColor`。 */
21
+ outlineMaterial?: Cesium.PolylineGraphics.ConstructorOptions['material'];
22
+ }
23
+ /**
24
+ * 可编辑多边形图形。
25
+ *
26
+ * 图形本体使用 Cesium Polygon,SDK 额外维护闭合 Polyline 描边、悬停高亮、顶点控制点和边中点。
27
+ */
28
+ declare class PolygonGraphic extends BaseGraphic {
29
+ /** 图形类型标识。 */
30
+ readonly type: 'PolygonGraphic';
31
+ /** 多边形顶点数组。 */
32
+ positions: Cesium.Cartesian3[];
33
+ /** Cesium PolygonGraphics 实例。 */
34
+ graphic: Cesium.PolygonGraphics;
35
+ /** 顶点数组更新后的业务回调。 */
36
+ onChanged: ((positions: Cesium.Cartesian3[]) => void) | undefined;
37
+ private changedDuringDrag;
38
+ private controlPoints;
39
+ private midPoints;
40
+ private positionsProperty;
41
+ private isHovering;
42
+ private hoverOutlineEntity;
43
+ private outlineEntity;
44
+ private outlineWidth;
45
+ private outlineMaterial;
46
+ private outlinePositionsProperty;
47
+ /**
48
+ * 创建多边形图形。
49
+ *
50
+ * @param opt 多边形图形配置。
51
+ */
52
+ constructor(opt: PolygonGraphicOptions);
53
+ /**
54
+ * 将多边形添加到图层。
55
+ *
56
+ * 添加后会创建 Polygon Entity,设置层级、中心锚点、标签和常态描边。
57
+ *
58
+ * @param layer 目标图层。
59
+ */
60
+ add(layer: GraphicLayer): void;
61
+ /** 创建常态边框:沿多边形周长的闭合 polyline,颜色从 material 提取或用 outlineColor */
62
+ private showOutline;
63
+ private clearOutline;
64
+ /** 从 polygon 的 material 中提取纯色(忽略透明度),用于边框 */
65
+ private extractOutlineColor;
66
+ /** 进入编辑模式,显示顶点控制点和边中点。 */
67
+ showHandler(): void;
68
+ /** 退出编辑模式,移除顶点控制点和边中点。 */
69
+ clearHandler(): void;
70
+ private showControlPoints;
71
+ private showMidPoints;
72
+ /** 拖拽热路径专用:原地更新中点坐标,实体不销毁重建,仅setValue */
73
+ private updateMidPointPositions;
74
+ /**
75
+ * 将边中点转换为新的顶点控制点。
76
+ *
77
+ * @param midPointIndex 被选中的中点索引。
78
+ */
79
+ convertMidPointToControlPoint(midPointIndex: number): void;
80
+ /** 显示鼠标悬停高亮描边。 */
81
+ onMouseMoveIn(): void;
82
+ /** 隐藏鼠标悬停高亮描边。 */
83
+ onMouseMoveOut(): void;
84
+ /**
85
+ * 显示悬停描边:一条沿多边形周长闭合的白色粗线
86
+ * 不修改多边形本体材质,避免 pick 丢失闪烁
87
+ */
88
+ private showHoverOutline;
89
+ private clearHoverOutline;
90
+ /**
91
+ * 响应顶点控制点拖拽移动。
92
+ *
93
+ * 移动后会同步 PolygonHierarchy、边中点和描边位置。`onChanged` 会在拖拽结束时触发。
94
+ *
95
+ * @param index 被移动的顶点索引。
96
+ * @param newPosition 顶点移动到的新位置。
97
+ */
98
+ onControlPointMoved(index: number, newPosition: Cesium.Cartesian3): void;
99
+ /** 控制点拖拽结束回调,刷新中心锚点并在顶点变化后触发 `onChanged`。 */
100
+ onControlPointDragEnd(): void;
101
+ /**
102
+ * 删除指定顶点控制点。
103
+ *
104
+ * 删除后会重建控制点和中点,并同步 PolygonHierarchy、描边和中心锚点。多边形至少保留 3 个顶点。
105
+ *
106
+ * @param index 要删除的顶点索引。
107
+ */
108
+ onControlPointDeleted(index: number): void;
109
+ private syncOutlinePositions;
110
+ private clearControlPoints;
111
+ private clearMidPoints;
112
+ /**
113
+ * 替换多边形全部顶点。
114
+ *
115
+ * @param targetPos 新的顶点数组。
116
+ */
117
+ updatePositions(targetPos: Cesium.Cartesian3[]): void;
118
+ /** 销毁多边形 Entity、描边、悬停高亮、编辑控制点和关联弹窗。 */
119
+ destroy(): void;
120
+ }
121
+ declare namespace PolygonGraphic {
122
+ type ConstructorOptions = PolygonGraphicOptions;
123
+ }
124
+ export default PolygonGraphic;
@@ -0,0 +1,100 @@
1
+ import BaseGraphic, { BaseGraphicOptions } from './baseGraphic';
2
+ import * as Cesium from 'cesium';
3
+ import { GraphicLayer } from '../layer';
4
+ /**
5
+ * 折线图形构造参数。
6
+ *
7
+ * 继承 Cesium `PolylineGraphics` 参数,并追加顶点数组和编辑回调。
8
+ */
9
+ export interface PolylineGraphicOptions extends Cesium.PolylineGraphics.ConstructorOptions, BaseGraphicOptions {
10
+ /** 折线顶点数组。 */
11
+ positions: Cesium.Cartesian3[];
12
+ /** 折线标签配置。 */
13
+ label?: Cesium.LabelGraphics.ConstructorOptions;
14
+ /** 顶点新增、移动或删除后触发。 */
15
+ onChanged?: (positions: Cesium.Cartesian3[]) => void;
16
+ }
17
+ /**
18
+ * 可编辑折线图形。
19
+ *
20
+ * 图形本体使用 Cesium Polyline,编辑模式下会显示顶点控制点和线段中点。
21
+ */
22
+ declare class PolylineGraphic extends BaseGraphic {
23
+ /** 图形类型标识。 */
24
+ readonly type: 'PolylineGraphic';
25
+ /** 折线顶点数组。 */
26
+ positions: Cesium.Cartesian3[];
27
+ /** Cesium PolylineGraphics 实例。 */
28
+ graphic: Cesium.PolylineGraphics;
29
+ /** 顶点数组更新后的业务回调。 */
30
+ onChanged: ((positions: Cesium.Cartesian3[]) => void) | undefined;
31
+ private changedDuringDrag;
32
+ private controlPoints;
33
+ private midPoints;
34
+ private positionsProperty;
35
+ private isHovering;
36
+ private hoverOutlineEntity;
37
+ /**
38
+ * 创建折线图形。
39
+ *
40
+ * @param opt 折线图形配置。
41
+ */
42
+ constructor(opt: PolylineGraphicOptions);
43
+ /**
44
+ * 将折线添加到图层。
45
+ *
46
+ * 添加后会创建 Polyline Entity,设置 positions 属性、中心锚点和标签。
47
+ *
48
+ * @param layer 目标图层。
49
+ */
50
+ add(layer: GraphicLayer): void;
51
+ /** 进入编辑模式,显示顶点控制点和线段中点。 */
52
+ showHandler(): void;
53
+ /** 退出编辑模式,移除顶点控制点和线段中点。 */
54
+ clearHandler(): void;
55
+ private showControlPoints;
56
+ private showMidPoints;
57
+ /** 拖拽热路径专用:原地更新中点坐标,实体不销毁重建,仅setValue */
58
+ private updateMidPointPositions;
59
+ /**
60
+ * 将线段中点转换为新的顶点控制点。
61
+ *
62
+ * @param midPointIndex 被选中的中点索引。
63
+ */
64
+ convertMidPointToControlPoint(midPointIndex: number): void;
65
+ /** 显示鼠标悬停高亮描边。 */
66
+ onMouseMoveIn(): void;
67
+ /** 隐藏鼠标悬停高亮描边。 */
68
+ onMouseMoveOut(): void;
69
+ private showHoverOutline;
70
+ private clearHoverOutline;
71
+ private getPolylineWidth;
72
+ private getPolylineZIndex;
73
+ /**
74
+ * 响应顶点控制点拖拽移动。
75
+ *
76
+ * 移动后会同步 Polyline positions 和中点位置。`onChanged` 会在拖拽结束时触发。
77
+ *
78
+ * @param index 被移动的顶点索引。
79
+ * @param newPosition 顶点移动到的新位置。
80
+ */
81
+ onControlPointMoved(index: number, newPosition: Cesium.Cartesian3): void;
82
+ /** 控制点拖拽结束回调,刷新中心锚点并在顶点变化后触发 `onChanged`。 */
83
+ onControlPointDragEnd(): void;
84
+ /**
85
+ * 删除指定顶点控制点。
86
+ *
87
+ * 删除后会重建控制点和中点,并同步 Polyline positions 与中心锚点。折线至少保留 2 个顶点。
88
+ *
89
+ * @param index 要删除的顶点索引。
90
+ */
91
+ onControlPointDeleted(index: number): void;
92
+ private clearControlPoints;
93
+ private clearMidPoints;
94
+ /** 销毁折线 Entity、悬停高亮、编辑控制点和关联弹窗。 */
95
+ destroy(): void;
96
+ }
97
+ declare namespace PolylineGraphic {
98
+ type ConstructorOptions = PolylineGraphicOptions;
99
+ }
100
+ export default PolylineGraphic;
@@ -0,0 +1,85 @@
1
+ import { DistanceDisplayCondition } from '../types';
2
+ import * as Cesium from 'cesium';
3
+ import { GraphicLayer } from '../layer';
4
+ import BaseGraphic, { BaseGraphicOptions } from './baseGraphic';
5
+ /**
6
+ * 内置弹窗构造参数。
7
+ *
8
+ * SDK 会根据标题和内容创建默认 DOM 结构,并在地图渲染后同步屏幕位置。
9
+ */
10
+ export interface PopupGraphicOptions extends BaseGraphicOptions {
11
+ /** 弹窗标题,支持 HTML 字符串。 */
12
+ title: string;
13
+ /** 弹窗内容,作为 HTML 写入默认内容容器。 */
14
+ content: string;
15
+ /** 弹窗可视距离范围,超过范围时自动隐藏。 */
16
+ distance?: DistanceDisplayCondition;
17
+ }
18
+ /**
19
+ * 内置 DOM 弹窗图形。
20
+ *
21
+ * 添加到图层后会创建默认黑色弹窗 DOM,并在 Cesium `postRender` 阶段跟随 `position` 更新屏幕位置。
22
+ */
23
+ declare class PopupGraphic extends BaseGraphic {
24
+ /** 图形类型标识。 */
25
+ readonly type: 'PopupGraphic';
26
+ /** 弹窗标题。 */
27
+ title: string;
28
+ /** 弹窗内容 HTML。 */
29
+ content: string;
30
+ /** 弹窗可视距离范围。 */
31
+ distance: DistanceDisplayCondition;
32
+ /** SDK 创建的弹窗 DOM 容器。 */
33
+ container: HTMLDivElement | null;
34
+ /** 弹窗是否处于业务关闭状态。 */
35
+ isClosed: boolean;
36
+ /** 地图容器左侧相对屏幕左侧的偏移。 */
37
+ left: number;
38
+ /**
39
+ * 创建内置弹窗图形。
40
+ *
41
+ * @param opt 弹窗配置。
42
+ */
43
+ constructor(opt: PopupGraphicOptions);
44
+ /**
45
+ * 将弹窗添加到图层并创建默认 DOM。
46
+ *
47
+ * @param layer 目标图层。
48
+ */
49
+ add(layer: GraphicLayer): void;
50
+ /** 销毁弹窗 DOM、postRender 监听和图层登记。 */
51
+ destroy(): void;
52
+ /** 注册 Cesium postRender 监听,用于每帧更新弹窗位置。 */
53
+ addListener(): void;
54
+ /** 移除 postRender 监听并隐藏弹窗。 */
55
+ clearListener(): void;
56
+ /** 显示弹窗。 */
57
+ show(): void;
58
+ /** 隐藏弹窗。 */
59
+ hide(): void;
60
+ /**
61
+ * 更新弹窗锚点、标题或内容。
62
+ *
63
+ * `title` 和 `content` 会写入默认 DOM,其中 `content` 按 HTML 处理。
64
+ *
65
+ * @param opt 可选更新项。
66
+ * @param opt.position 新锚点位置。
67
+ * @param opt.title 新标题。
68
+ * @param opt.content 新内容 HTML。
69
+ */
70
+ updateLabel(opt?: {
71
+ position?: Cesium.Cartesian3;
72
+ title?: string;
73
+ content?: string;
74
+ }): void;
75
+ /**
76
+ * Cesium postRender 回调。
77
+ *
78
+ * 根据锚点屏幕坐标、视口范围、相机距离和关闭状态更新 DOM 显隐与位置。
79
+ */
80
+ Postshow(): void;
81
+ }
82
+ declare namespace PopupGraphic {
83
+ type ConstructorOptions = PopupGraphicOptions;
84
+ }
85
+ export default PopupGraphic;
@@ -0,0 +1,96 @@
1
+ import { GraphicType } from '../graphic';
2
+ import type KeyMap from '../map';
3
+ import { Asset } from '../types';
4
+ import * as Cesium from 'cesium';
5
+ /**
6
+ * 图形图层。
7
+ *
8
+ * `GraphicLayer` 用于承载 `graphic` 模块下的 Entity 图形资产。图形添加到图层后,
9
+ * 图层会记录子资产信息,并把资产同步登记到 `KeyMap.Assets`,便于统一查询、显隐和销毁。
10
+ */
11
+ export default class GraphicLayer {
12
+ /** 图层唯一 id,用于地图图层列表和资产关联。 */
13
+ id: string;
14
+ /** 图层名称,不传时自动使用 `GraphicLayer_id`。 */
15
+ name: string | null;
16
+ /** 图层类型标识。 */
17
+ type: string;
18
+ /** 当前图层关联的 Cesium Viewer,初始化前为 `null`。 */
19
+ viewer: Cesium.Viewer | null;
20
+ /** 当前图层所属的 `KeyMap` 实例,初始化前为 `null`。 */
21
+ map: KeyMap | null;
22
+ /**
23
+ * 图层下子资产的轻量索引。
24
+ *
25
+ * 这里只保存 id、name、type,真实资产对象存放在 `KeyMap.Assets` 中。
26
+ */
27
+ children: {
28
+ id: string;
29
+ name: string | null;
30
+ type: string;
31
+ }[];
32
+ /**
33
+ * 创建图形图层。
34
+ *
35
+ * @param opt 图层配置。
36
+ * @param opt.name 自定义图层名称。
37
+ * @param opt.id 自定义图层 id。
38
+ */
39
+ constructor(opt?: {
40
+ name?: string;
41
+ id?: string;
42
+ });
43
+ /**
44
+ * 初始化图层并挂载到地图。
45
+ *
46
+ * 通常由 `map.addLayer(layer)` 调用,业务侧不需要直接调用。
47
+ *
48
+ * @param map 当前地图实例。
49
+ */
50
+ init(map: KeyMap): void;
51
+ /**
52
+ * 添加图形资产到当前图层。
53
+ *
54
+ * 图形会执行自己的 `add(layer)` 方法,并在其中登记到图层和全局资产管理器。
55
+ *
56
+ * @param graphic 要添加的图形资产。
57
+ */
58
+ addGraphic(graphic: GraphicType): void;
59
+ /**
60
+ * 销毁图层。
61
+ *
62
+ * 会先移除图层下全部子资产,再从地图图层列表中删除当前图层引用。
63
+ */
64
+ destroy(): void;
65
+ /**
66
+ * 登记子资产。
67
+ *
68
+ * 通常由图形的 `add(layer)` 内部调用,会把资产加入 `KeyMap.Assets`,并在图层中保存轻量索引。
69
+ *
70
+ * @param child 要登记的子资产。
71
+ */
72
+ addChild(child: Asset): void;
73
+ /** 移除并销毁当前图层下的全部子资产。 */
74
+ removeAll(): void;
75
+ /**
76
+ * 从图层中删除指定子资产。
77
+ *
78
+ * 会同步调用 `KeyMap.Assets.removeById(id)` 销毁真实资产。
79
+ *
80
+ * @param id 子资产 id。
81
+ */
82
+ removeChild(id: string): void;
83
+ /**
84
+ * 将子资产从图层索引中解绑。
85
+ *
86
+ * 与 `removeChild()` 不同,该方法只解除图层登记并从 `KeyMap.Assets` 中 detach,
87
+ * 适合资产自身销毁流程中避免重复调用图层删除。
88
+ *
89
+ * @param id 子资产 id。
90
+ */
91
+ detachChild(id: string): void;
92
+ /** 显示当前图层下所有支持 `show()` 的子资产。 */
93
+ show(): void;
94
+ /** 隐藏当前图层下所有支持 `hide()` 的子资产。 */
95
+ hide(): void;
96
+ }
@@ -0,0 +1,39 @@
1
+ /** 负责热力图 纯canvas 的绘制 */
2
+ import * as Cesium from 'cesium';
3
+ /** 热力图经纬度权重点。 */
4
+ export interface HeatmapPoint {
5
+ /** 经度,单位为度。 */
6
+ lng: number;
7
+ /** 纬度,单位为度。 */
8
+ lat: number;
9
+ /** 当前点权重值。 */
10
+ value: number;
11
+ }
12
+ /** 热力图渐变色节点。 */
13
+ export interface HeatmapGradientStop {
14
+ /** 渐变位置,范围为 `0` 到 `1`。 */
15
+ offset: number;
16
+ /** CSS 颜色字符串。 */
17
+ color: string;
18
+ }
19
+ /** 热力图数值范围。 */
20
+ export interface HeatmapValueRange {
21
+ /** 最小值,小于该值的点按最低热度处理。 */
22
+ min: number;
23
+ /** 最大值,大于该值的点按最高热度处理。 */
24
+ max: number;
25
+ }
26
+ export interface HeatmapRenderOptions {
27
+ readonly points: readonly HeatmapPoint[];
28
+ readonly rectangle: Cesium.Rectangle;
29
+ readonly width: number;
30
+ readonly height: number;
31
+ readonly radius: number;
32
+ readonly blur: number;
33
+ readonly gradient: readonly HeatmapGradientStop[];
34
+ readonly range: HeatmapValueRange;
35
+ }
36
+ export declare const HEATMAP_DEFAULT_GRADIENT: readonly HeatmapGradientStop[];
37
+ export declare function resolveHeatmapRange(points: readonly HeatmapPoint[], min?: number, max?: number): HeatmapValueRange;
38
+ /** 将经纬度权重点渲染为可作为 Cesium 图片材质使用的 canvas。 */
39
+ export declare function renderHeatmap(canvas: HTMLCanvasElement, options: HeatmapRenderOptions): void;
@@ -0,0 +1,113 @@
1
+ import type KeyMap from '../map';
2
+ import * as Cesium from 'cesium';
3
+ import type { HeatmapGradientStop, HeatmapPoint, HeatmapValueRange } from './heatmapLayer/heatmapRenderer';
4
+ export type { HeatmapGradientStop, HeatmapPoint, HeatmapValueRange } from './heatmapLayer/heatmapRenderer';
5
+ /** 热力图图层构造参数。 */
6
+ export interface HeatmapLayerOptions {
7
+ /** 图层唯一 id,不传时自动生成。 */
8
+ id?: string;
9
+ /** 图层名称,不传时自动使用 `HeatmapLayer_id`。 */
10
+ name?: string;
11
+ /** 热力图覆盖范围。 */
12
+ rectangle: Cesium.Rectangle;
13
+ /** 经纬度权重点。 */
14
+ points?: readonly HeatmapPoint[];
15
+ /** 热力图 canvas 宽度。 */
16
+ width?: number;
17
+ /** 热力图 canvas 高度。 */
18
+ height?: number;
19
+ /** 单点影响半径,单位像素。 */
20
+ radius?: number;
21
+ /** 中心实心区域比例,范围为 `0` 到 `1`。 */
22
+ blur?: number;
23
+ /** 固定最小值。实时数据建议设置,避免颜色语义漂移。 */
24
+ min?: number;
25
+ /** 固定最大值。实时数据建议设置,避免颜色语义漂移。 */
26
+ max?: number;
27
+ /** CSS 渐变色节点。 */
28
+ gradient?: readonly HeatmapGradientStop[];
29
+ /** 图层整体透明度,范围为 `0` 到 `1`。 */
30
+ opacity?: number;
31
+ }
32
+ /** 更新热力图渲染配置。 */
33
+ export interface HeatmapRenderUpdateOptions {
34
+ /** 热力图覆盖范围。 */
35
+ rectangle?: Cesium.Rectangle;
36
+ /** 热力图 canvas 宽度。 */
37
+ width?: number;
38
+ /** 热力图 canvas 高度。 */
39
+ height?: number;
40
+ /** 单点影响半径,单位像素。 */
41
+ radius?: number;
42
+ /** 中心实心区域比例,范围为 `0` 到 `1`。 */
43
+ blur?: number;
44
+ /** CSS 渐变色节点。 */
45
+ gradient?: readonly HeatmapGradientStop[];
46
+ /** 图层整体透明度,范围为 `0` 到 `1`。 */
47
+ opacity?: number;
48
+ }
49
+ /**
50
+ * 二维热力图图层。
51
+ *
52
+ * `HeatmapLayer` 会把经纬度权重点绘制到 canvas,再作为 Cesium rectangle 图片材质贴到指定地理范围。
53
+ * 适合校园人流密度、区域热度等二维覆盖场景;首版不做地形贴合或 3D 拉伸。
54
+ */
55
+ export default class HeatmapLayer {
56
+ /** 图层唯一 id。 */
57
+ id: string;
58
+ /** 图层名称。 */
59
+ name: string;
60
+ /** 图层类型标识。 */
61
+ type: string;
62
+ /** 当前图层所属的 `KeyMap` 实例,初始化前为 `null`。 */
63
+ map: KeyMap | null;
64
+ /** 当前图层关联的 Cesium Viewer,初始化前为 `null`。 */
65
+ viewer: Cesium.Viewer | null;
66
+ /** 热力图覆盖范围。 */
67
+ rectangle: Cesium.Rectangle;
68
+ /** 当前热力图数据范围。 */
69
+ range: HeatmapValueRange;
70
+ private readonly canvas;
71
+ private min?;
72
+ private max?;
73
+ private points;
74
+ private width;
75
+ private height;
76
+ private radius;
77
+ private blur;
78
+ private gradient;
79
+ private opacity;
80
+ private entity;
81
+ /**
82
+ * 创建二维热力图图层。
83
+ *
84
+ * @param opt 热力图图层配置。
85
+ */
86
+ constructor(opt: HeatmapLayerOptions);
87
+ /**
88
+ * 初始化图层并挂载到地图。
89
+ *
90
+ * 通常由 `map.addLayer(layer)` 调用。
91
+ *
92
+ * @param map 当前地图实例。
93
+ */
94
+ init(map: KeyMap): void;
95
+ /** 使用新的权重点数据重新渲染热力图。 */
96
+ setData(points: readonly HeatmapPoint[]): void;
97
+ /** 设置固定数值范围并重新渲染热力图。 */
98
+ setRange(range: HeatmapValueRange): void;
99
+ /** 更新覆盖范围并重新渲染热力图。 */
100
+ setRectangle(rectangle: Cesium.Rectangle): void;
101
+ /** 更新渲染参数并重新渲染热力图。 */
102
+ updateOptions(options: HeatmapRenderUpdateOptions): void;
103
+ /** 按当前配置重新绘制 canvas。 */
104
+ render(): void;
105
+ /** 显示热力图图层。 */
106
+ show(): void;
107
+ /** 隐藏热力图图层。 */
108
+ hide(): void;
109
+ /** 销毁热力图实体并解绑图层登记。 */
110
+ destroy(): void;
111
+ private updateEntityMaterial;
112
+ private detachLayer;
113
+ }