@hzab/map-combine 0.4.2-alpha.1 → 0.4.2-alpha.12
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/CHANGELOG.md +8 -0
- package/package.json +5 -5
- package/src/amap/AMap.ts +318 -306
- package/src/amap/AMapEvent.ts +110 -54
- package/src/amap/AMapLayer.ts +241 -0
- package/src/amap/AMapPoint.ts +140 -143
- package/src/amap/AMapPolygon.ts +214 -195
- package/src/amap/AMapPolyline.ts +199 -185
- package/src/basic/BasicBusiness.ts +5 -5
- package/src/basic/BasicModel.ts +49 -0
- package/src/basic/Layer.ts +154 -0
- package/src/basic/MapCombine.ts +105 -98
- package/src/basic/MapElement.ts +2 -1
- package/src/basic/MapEvent.ts +5 -0
- package/src/basic/Point.ts +1 -0
- package/src/basic/PointAggregation.tsx +22 -11
- package/src/basic/ReactPopup.tsx +3 -0
- package/src/basic/Tile3D.ts +0 -1
- package/src/cesium/CesiumEvent.ts +97 -84
- package/src/cesium/CesiumLayer.ts +365 -0
- package/src/cesium/CesiumMap.ts +363 -347
- package/src/cesium/CesiumModel.ts +64 -0
- package/src/cesium/CesiumPoint.ts +3 -0
- package/src/cesium/CesiumPolygon.ts +2 -0
- package/src/cesium/CesiumPolyline.ts +185 -47
- package/src/cesium/CesiumTile3D.ts +222 -225
- package/src/mine/MineEvent.ts +70 -46
- package/src/mine/MineMap.ts +217 -125
- package/src/mine/MinePoint.ts +7 -1
- package/src/mine/MinePolygon.ts +6 -1
- package/src/mine/MinePolyline.ts +6 -1
- package/src/openlayer/OpenlayerEvent.ts +109 -87
- package/src/openlayer/OpenlayerMap.ts +33 -6
- package/src/openlayer/OpenlayerPoint.ts +6 -1
- package/src/openlayer/OpenlayerPolygon.ts +6 -1
- package/src/openlayer/OpenlayerPolyline.ts +8 -1
- package/src/utils/color.ts +49 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/points-viewer.ts +27 -1
- package/src/utils/turfjs-utils.ts +52 -0
- package/src/utils/types.d.ts +12 -0
package/src/basic/MapCombine.ts
CHANGED
|
@@ -1,98 +1,105 @@
|
|
|
1
|
-
import { ContextMenu } from "./ContextMenu";
|
|
2
|
-
import { MapElement } from "./MapElement";
|
|
3
|
-
import { MapEvent } from "./MapEvent";
|
|
4
|
-
import { Point, PointOption } from "./Point";
|
|
5
|
-
import { PointAggregation, PointAggregationOption } from "./PointAggregation";
|
|
6
|
-
import { Polygon, PolygonOption } from "./Polygon";
|
|
7
|
-
import { Polyline, PolylineOption } from "./Polyline";
|
|
8
|
-
import { ReactPoint, ReactPointOption, drawReactPoint } from "./ReactPoint";
|
|
9
|
-
import { Tile3D, Tile3DOption } from "./Tile3D";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
readonly
|
|
19
|
-
readonly
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
abstract
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
abstract
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
abstract
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
htmllayer
|
|
42
|
-
htmllayer.style.
|
|
43
|
-
htmllayer.style.
|
|
44
|
-
htmllayer.style.
|
|
45
|
-
htmllayer.style.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
*
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
abstract
|
|
70
|
-
|
|
71
|
-
abstract
|
|
72
|
-
|
|
73
|
-
abstract
|
|
74
|
-
|
|
75
|
-
abstract
|
|
76
|
-
|
|
77
|
-
abstract
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
*
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
1
|
+
import { ContextMenu } from "./ContextMenu";
|
|
2
|
+
import { MapElement } from "./MapElement";
|
|
3
|
+
import { MapEvent } from "./MapEvent";
|
|
4
|
+
import { Point, PointOption } from "./Point";
|
|
5
|
+
import { PointAggregation, PointAggregationOption } from "./PointAggregation";
|
|
6
|
+
import { Polygon, PolygonOption } from "./Polygon";
|
|
7
|
+
import { Polyline, PolylineOption } from "./Polyline";
|
|
8
|
+
import { ReactPoint, ReactPointOption, drawReactPoint } from "./ReactPoint";
|
|
9
|
+
import { Tile3D, Tile3DOption } from "./Tile3D";
|
|
10
|
+
import { BasicModel, BasicModelOption } from "./BasicModel";
|
|
11
|
+
import { type BasicBusiness, type BasicBusinessOption } from "./BasicBusiness";
|
|
12
|
+
|
|
13
|
+
import { getBounds } from "../utils/points-viewer";
|
|
14
|
+
import { Layer, LayerOption } from "./Layer";
|
|
15
|
+
|
|
16
|
+
export abstract class MapCombine {
|
|
17
|
+
/* 用于挂载html元素的根节点 */
|
|
18
|
+
readonly htmllayer = document.createElement("div");
|
|
19
|
+
readonly elements = new Map<string, MapElement>();
|
|
20
|
+
readonly event = new MapEvent();
|
|
21
|
+
readonly menu: ContextMenu;
|
|
22
|
+
abstract get cursor(): string;
|
|
23
|
+
abstract set cursor(val: string);
|
|
24
|
+
|
|
25
|
+
abstract get moveable(): boolean;
|
|
26
|
+
abstract set moveable(val: boolean);
|
|
27
|
+
|
|
28
|
+
abstract get center(): number[];
|
|
29
|
+
abstract set center(val);
|
|
30
|
+
|
|
31
|
+
abstract get zoom(): number;
|
|
32
|
+
abstract set zoom(val);
|
|
33
|
+
|
|
34
|
+
loadPromise: Promise<this> = Promise.resolve(this);
|
|
35
|
+
|
|
36
|
+
bussinesses = new Map<string, BasicBusiness<BasicBusinessOption>>();
|
|
37
|
+
|
|
38
|
+
/** 地图是否存在 */
|
|
39
|
+
isAlive = true;
|
|
40
|
+
constructor() {
|
|
41
|
+
const { htmllayer } = this;
|
|
42
|
+
htmllayer.style.zIndex = "1000";
|
|
43
|
+
htmllayer.style.position = "absolute";
|
|
44
|
+
htmllayer.style.width = "0";
|
|
45
|
+
htmllayer.style.height = "0";
|
|
46
|
+
htmllayer.style.left = "0";
|
|
47
|
+
htmllayer.style.top = "0";
|
|
48
|
+
this.menu = new ContextMenu(this);
|
|
49
|
+
(window as any).map = this;
|
|
50
|
+
setTimeout(() => {
|
|
51
|
+
this.bussinesses.forEach((e) => e.show && e.onMapLoaded?.());
|
|
52
|
+
}, 100);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
createReactPoint<K>(option?: Partial<ReactPointOption<K>>): ReactPoint<K> {
|
|
56
|
+
const e = new ReactPoint(this, option);
|
|
57
|
+
drawReactPoint(this, e);
|
|
58
|
+
return e;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 设置地图视图
|
|
63
|
+
* @param option 视图参数
|
|
64
|
+
* @param time 设置时间会动画形式调整视图
|
|
65
|
+
*/
|
|
66
|
+
abstract createPoint<K>(option?: Partial<PointOption<K>>): Point<K>;
|
|
67
|
+
|
|
68
|
+
/** 聚合点 */
|
|
69
|
+
abstract createPointAggregation(option?: PointAggregationOption): PointAggregation;
|
|
70
|
+
|
|
71
|
+
abstract createPolyline<K>(option?: Partial<PolylineOption<K>>): Polyline<K>;
|
|
72
|
+
|
|
73
|
+
abstract createPolygon<K>(option?: Partial<PolygonOption<K>>): Polygon<K>;
|
|
74
|
+
|
|
75
|
+
abstract createTile3D(option?: Partial<Tile3DOption>): Tile3D;
|
|
76
|
+
|
|
77
|
+
abstract createLayer(option?: Partial<LayerOption>): Layer;
|
|
78
|
+
|
|
79
|
+
/** 创建模型 */
|
|
80
|
+
createModel?(option?: Partial<BasicModelOption>): BasicModel;
|
|
81
|
+
|
|
82
|
+
abstract canvasTgeography(p: number[]): number[];
|
|
83
|
+
|
|
84
|
+
abstract geographyTcanvas(p: number[]): number[];
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 所有点位移动至视口,调整位置及层级
|
|
88
|
+
* @param points
|
|
89
|
+
*/
|
|
90
|
+
abstract flyToViewer(points: number[][], opt?: Object): void;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 移动点位到中心点
|
|
94
|
+
* @param points
|
|
95
|
+
*/
|
|
96
|
+
abstract flyTo(point: number[], opt?: Object): void;
|
|
97
|
+
|
|
98
|
+
getBounds = getBounds;
|
|
99
|
+
|
|
100
|
+
destroy() {
|
|
101
|
+
this.isAlive = false;
|
|
102
|
+
this.htmllayer.remove();
|
|
103
|
+
this.event.trigger("destroy");
|
|
104
|
+
}
|
|
105
|
+
}
|
package/src/basic/MapElement.ts
CHANGED
|
@@ -16,7 +16,8 @@ export abstract class MapElement<T extends MapElementOption = MapElementOption>
|
|
|
16
16
|
this.map = map;
|
|
17
17
|
this._option = option;
|
|
18
18
|
if (map.elements.has(option.name)) {
|
|
19
|
-
|
|
19
|
+
console.error(new Error(`已存在同名元素 ${option.name}`));
|
|
20
|
+
return;
|
|
20
21
|
}
|
|
21
22
|
map.elements.set(option.name, this);
|
|
22
23
|
}
|
package/src/basic/MapEvent.ts
CHANGED
|
@@ -5,6 +5,11 @@ export class MapEvent extends Eventful<{
|
|
|
5
5
|
"pointer-move": () => void;
|
|
6
6
|
"pointer-up": () => void;
|
|
7
7
|
"left-click": () => void;
|
|
8
|
+
/**
|
|
9
|
+
* 获取当前点击位置的所有元素
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
"drill-pick": (elements) => void;
|
|
8
13
|
"right-click": () => void;
|
|
9
14
|
"double-click": () => void;
|
|
10
15
|
"view-change": () => void;
|
package/src/basic/Point.ts
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import { ReactElement } from "react";
|
|
2
|
-
import { throttle } from "lodash";
|
|
3
2
|
|
|
4
3
|
import { LATTOONE, LONTOONE } from "../utils/static";
|
|
5
4
|
import { getUUID, setValue } from "../utils";
|
|
6
5
|
import { MapCombine } from "../basic/MapCombine";
|
|
7
6
|
import { ReactPoint } from "./ReactPoint";
|
|
8
7
|
|
|
8
|
+
export interface PointOption {
|
|
9
|
+
coordinates: number[];
|
|
10
|
+
props?: any;
|
|
11
|
+
}
|
|
9
12
|
export interface PointAggregationOption {
|
|
10
13
|
/** 组件名,唯一标识 */
|
|
11
14
|
name: string;
|
|
12
15
|
/** 组件是否显示 */
|
|
13
16
|
show: boolean;
|
|
14
17
|
/** 数据点 */
|
|
15
|
-
datas:
|
|
18
|
+
datas: PointOption[];
|
|
16
19
|
/** 小于该值的等级下会聚合 */
|
|
17
20
|
maxZoomLevel?: number;
|
|
18
21
|
/** 值越大聚合点的间距越小 */
|
|
19
22
|
density?: number;
|
|
20
23
|
/** 点的展示元素 */
|
|
21
|
-
element(datas:
|
|
24
|
+
element(datas: PointOption[], p: number[]): ReactElement;
|
|
22
25
|
/** 坐标处理回调 */
|
|
23
26
|
location(lonlat: number[]): number[];
|
|
24
27
|
}
|
|
@@ -28,10 +31,12 @@ class TileNode {
|
|
|
28
31
|
private _element: any;
|
|
29
32
|
marker: ReactPoint | undefined;
|
|
30
33
|
private _map: MapCombine;
|
|
31
|
-
|
|
34
|
+
option;
|
|
35
|
+
constructor(map: MapCombine, location: number[], element: ReactElement, option = {}) {
|
|
32
36
|
this._map = map;
|
|
33
37
|
this._location = location;
|
|
34
38
|
this._element = element;
|
|
39
|
+
this.option = option;
|
|
35
40
|
}
|
|
36
41
|
test(east: number, south: number, west: number, north: number) {
|
|
37
42
|
if (
|
|
@@ -42,6 +47,7 @@ class TileNode {
|
|
|
42
47
|
) {
|
|
43
48
|
if (!this.marker) {
|
|
44
49
|
const option = {
|
|
50
|
+
...this.option,
|
|
45
51
|
show: true,
|
|
46
52
|
name: getUUID(),
|
|
47
53
|
element: () => this._element,
|
|
@@ -94,6 +100,8 @@ export class PointAggregation {
|
|
|
94
100
|
this._onAfterViewChange = this.onAfterViewChange.bind(this);
|
|
95
101
|
this.onAfterViewChange();
|
|
96
102
|
event.on("view-moveEnd", this._onAfterViewChange);
|
|
103
|
+
// 初始化没有渲染,移动之后才渲染点位
|
|
104
|
+
this._update();
|
|
97
105
|
}
|
|
98
106
|
|
|
99
107
|
private _turnon(zoom: number) {
|
|
@@ -106,10 +114,12 @@ export class PointAggregation {
|
|
|
106
114
|
const grid = new Map();
|
|
107
115
|
const max = Math.pow(2, zoom) * (_option.density ?? 1);
|
|
108
116
|
_option.datas.forEach((data) => {
|
|
109
|
-
const location =
|
|
117
|
+
const location =
|
|
118
|
+
typeof _option.location === "function" ? _option.location(data.coordinates) : data.coordinates;
|
|
110
119
|
const x = Math.floor(LONTOONE.forward(location[0]) * max * 2);
|
|
111
120
|
const y = Math.floor(LATTOONE.forward(location[1]) * max);
|
|
112
121
|
const k = `${x}_${y}`;
|
|
122
|
+
// 对数据进行分组
|
|
113
123
|
const group = grid.get(k);
|
|
114
124
|
if (group) {
|
|
115
125
|
group.push(data);
|
|
@@ -118,10 +128,11 @@ export class PointAggregation {
|
|
|
118
128
|
}
|
|
119
129
|
});
|
|
120
130
|
// 处理聚合点坐标
|
|
121
|
-
grid.forEach((
|
|
122
|
-
const { lon, lat } =
|
|
131
|
+
grid.forEach((group) => {
|
|
132
|
+
const { lon, lat } = group?.reduce(
|
|
123
133
|
(a, b) => {
|
|
124
|
-
const
|
|
134
|
+
const { coordinates } = b;
|
|
135
|
+
const loaction = typeof _option.location === "function" ? _option.location(coordinates) : coordinates;
|
|
125
136
|
a.lon += loaction[0];
|
|
126
137
|
a.lat += loaction[1];
|
|
127
138
|
return a;
|
|
@@ -131,8 +142,8 @@ export class PointAggregation {
|
|
|
131
142
|
cache.push(
|
|
132
143
|
new TileNode(
|
|
133
144
|
this._map,
|
|
134
|
-
[lon /
|
|
135
|
-
_option.element(
|
|
145
|
+
[lon / group.length, lat / group.length],
|
|
146
|
+
_option.element(group, [lon / group.length, lat / group.length]),
|
|
136
147
|
),
|
|
137
148
|
);
|
|
138
149
|
});
|
|
@@ -140,7 +151,7 @@ export class PointAggregation {
|
|
|
140
151
|
} else {
|
|
141
152
|
const cache: TileNode[] = [];
|
|
142
153
|
_option.datas.forEach((e) => {
|
|
143
|
-
const location = _option.location(e);
|
|
154
|
+
const location = _option.location(e.coordinates);
|
|
144
155
|
cache.push(new TileNode(this._map, location, _option.element([e], location)));
|
|
145
156
|
});
|
|
146
157
|
_cache.set(zoom, cache);
|
package/src/basic/ReactPopup.tsx
CHANGED
package/src/basic/Tile3D.ts
CHANGED
|
@@ -105,7 +105,6 @@ export class Tile3D extends MapElement<Tile3DOption> {
|
|
|
105
105
|
console.info("TileD translate");
|
|
106
106
|
}
|
|
107
107
|
/** 基于本地的 ENU 坐标系的旋转,也就是垂直于地表向上为 Z,东为 X,北为 Y
|
|
108
|
-
* https://blog.csdn.net/weixin_70945905/article/details/142419968
|
|
109
108
|
* @param rx 绕X轴旋转的角度。单位:度
|
|
110
109
|
* @param ry 绕Y轴旋转的角度。单位:度
|
|
111
110
|
* @param rz 绕Z轴旋转的角度。单位:度
|
|
@@ -1,84 +1,97 @@
|
|
|
1
|
-
import { CesiumMap } from "./CesiumMap";
|
|
2
|
-
|
|
3
|
-
export function bindEvent(map: CesiumMap) {
|
|
4
|
-
const { event, viewer, container } = map;
|
|
5
|
-
viewer.camera.percentageChanged = 0.0001;
|
|
6
|
-
|
|
7
|
-
viewer.scene.preRender.addEventListener(() => {
|
|
8
|
-
event.trigger("view-preRender");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
event.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
target
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
map.cursor =
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}, Cesium.ScreenSpaceEventType.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
1
|
+
import { CesiumMap } from "./CesiumMap";
|
|
2
|
+
|
|
3
|
+
export function bindEvent(map: CesiumMap) {
|
|
4
|
+
const { event, viewer, container } = map;
|
|
5
|
+
viewer.camera.percentageChanged = 0.0001;
|
|
6
|
+
|
|
7
|
+
viewer.scene.preRender.addEventListener(() => {
|
|
8
|
+
event.trigger("view-preRender");
|
|
9
|
+
map.bussinesses.forEach((e) => e.show && e.onFrame?.());
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
viewer.camera.changed.addEventListener(() => {
|
|
13
|
+
event.trigger("view-change");
|
|
14
|
+
});
|
|
15
|
+
viewer.camera.moveEnd.addEventListener(() => {
|
|
16
|
+
event.trigger("view-moveEnd");
|
|
17
|
+
});
|
|
18
|
+
const handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas);
|
|
19
|
+
let target: any;
|
|
20
|
+
handler.setInputAction((e: any) => {
|
|
21
|
+
event.canvas = [e.endPosition.x, e.endPosition.y];
|
|
22
|
+
event.geography = map.canvasTgeography(event.canvas);
|
|
23
|
+
let _target: any = undefined;
|
|
24
|
+
const res = viewer.scene.pick(e.endPosition);
|
|
25
|
+
|
|
26
|
+
const a = res ? (res.id ? res.id : res.primitive ? res.primitive : undefined) : undefined;
|
|
27
|
+
|
|
28
|
+
if (a && !a.silent) {
|
|
29
|
+
_target = a;
|
|
30
|
+
}
|
|
31
|
+
if (_target !== target) {
|
|
32
|
+
target?.onPointerOut?.();
|
|
33
|
+
_target?.onPointerIn?.();
|
|
34
|
+
target = _target;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (target) {
|
|
38
|
+
map.cursor = target.cursor;
|
|
39
|
+
} else {
|
|
40
|
+
map.cursor = "";
|
|
41
|
+
}
|
|
42
|
+
event.trigger("pointer-move");
|
|
43
|
+
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
|
44
|
+
|
|
45
|
+
handler.setInputAction(() => {
|
|
46
|
+
if (target) {
|
|
47
|
+
target.onPointerDown?.();
|
|
48
|
+
}
|
|
49
|
+
event.trigger("pointer-down");
|
|
50
|
+
}, Cesium.ScreenSpaceEventType.LEFT_DOWN);
|
|
51
|
+
|
|
52
|
+
// 解决 ReactPoint 点击事件无法触发的问题
|
|
53
|
+
container.addEventListener("click", () => {
|
|
54
|
+
event.trigger("left-click");
|
|
55
|
+
});
|
|
56
|
+
container.addEventListener("pointerup", () => {
|
|
57
|
+
if (target) {
|
|
58
|
+
target.onPointerUp?.();
|
|
59
|
+
}
|
|
60
|
+
event.trigger("pointer-up");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
handler.setInputAction((e) => {
|
|
64
|
+
if (target) {
|
|
65
|
+
target.onLClick?.();
|
|
66
|
+
}
|
|
67
|
+
event.trigger("left-click");
|
|
68
|
+
|
|
69
|
+
// 穿透拾取,获取点击位置的所有对象
|
|
70
|
+
const pickedObjects = viewer.scene.drillPick(e.position);
|
|
71
|
+
if (pickedObjects && pickedObjects.length > 0) {
|
|
72
|
+
event.trigger("drill-pick", {
|
|
73
|
+
event: e,
|
|
74
|
+
pickedTargets: pickedObjects.map((it) => it.id?.target),
|
|
75
|
+
sourceObjects: pickedObjects,
|
|
76
|
+
position: e.position,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
80
|
+
handler.setInputAction(() => {
|
|
81
|
+
if (target) {
|
|
82
|
+
target.onRClick?.();
|
|
83
|
+
}
|
|
84
|
+
event.trigger("right-click");
|
|
85
|
+
}, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
|
|
86
|
+
|
|
87
|
+
handler.setInputAction(() => {
|
|
88
|
+
if (target) {
|
|
89
|
+
target.onDbClick?.();
|
|
90
|
+
}
|
|
91
|
+
event.trigger("double-click");
|
|
92
|
+
}, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
|
|
93
|
+
|
|
94
|
+
event.on("destroy", () => {
|
|
95
|
+
viewer.destroy();
|
|
96
|
+
});
|
|
97
|
+
}
|