@hzab/map-combine 0.4.2-alpha.3 → 0.4.2-alpha.4
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 +1 -0
- package/package.json +4 -3
- package/src/amap/AMap.ts +313 -306
- package/src/amap/AMapPoint.ts +77 -89
- package/src/cesium/CesiumMap.ts +358 -358
- package/src/utils/index.ts +3 -0
package/src/amap/AMapPoint.ts
CHANGED
|
@@ -1,89 +1,76 @@
|
|
|
1
1
|
import { Point } from "../basic/Point";
|
|
2
2
|
import { AMap } from "./AMap";
|
|
3
3
|
|
|
4
|
-
const RD = 0.017453292519943295;
|
|
5
|
-
|
|
6
4
|
export function drawPoint(map: AMap, point: Point<unknown>) {
|
|
7
5
|
const { viewer, event, LbsAMap } = map;
|
|
8
6
|
let status = 0;
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
point.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
onPointerUp() {
|
|
31
|
-
if (point.editable && status == 3) {
|
|
32
|
-
status = 2;
|
|
33
|
-
map.moveable = true;
|
|
34
|
-
point.coordinates = [event.geography[0], event.geography[1], point.coordinates[2] ?? point.height];
|
|
35
|
-
point.event.trigger("data-update");
|
|
36
|
-
}
|
|
7
|
+
let skip = 0;
|
|
8
|
+
|
|
9
|
+
const { size, center } = point;
|
|
10
|
+
const pointOffset = [-size[0] * center[0], -size[1] * center[1]];
|
|
11
|
+
const marker = new LbsAMap.Marker({
|
|
12
|
+
position: new LbsAMap.LngLat(0, 0),
|
|
13
|
+
height: point.height,
|
|
14
|
+
title: point._option.name,
|
|
15
|
+
icon: new LbsAMap.Icon({
|
|
16
|
+
image: point.src,
|
|
17
|
+
size: point.size,
|
|
18
|
+
imageSize: point.size,
|
|
19
|
+
}),
|
|
20
|
+
angle: point.rotation,
|
|
21
|
+
anchor: point.center,
|
|
22
|
+
draggable: point.editable,
|
|
23
|
+
extData: {
|
|
24
|
+
cursor: point.cursor,
|
|
25
|
+
silent: point.silent,
|
|
37
26
|
},
|
|
38
|
-
|
|
27
|
+
offset: pointOffset,
|
|
28
|
+
});
|
|
29
|
+
setIcon();
|
|
30
|
+
viewer.add([marker]);
|
|
39
31
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
32
|
+
if (point.coordinates) {
|
|
33
|
+
status = 2;
|
|
34
|
+
marker.setPosition(point.coordinates);
|
|
35
|
+
if (point.show) {
|
|
36
|
+
marker.show();
|
|
37
|
+
} else {
|
|
38
|
+
marker.hide();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
46
41
|
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
64
|
-
bindEvent(marker);
|
|
65
|
-
viewer.add([marker]);
|
|
42
|
+
const onMouseMove = () => {
|
|
43
|
+
switch (status) {
|
|
44
|
+
case 0:
|
|
45
|
+
status = 1;
|
|
46
|
+
marker.setPosition(event.geography);
|
|
47
|
+
if (point.show) {
|
|
48
|
+
marker.show();
|
|
49
|
+
} else {
|
|
50
|
+
marker.hide();
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
53
|
+
case 1:
|
|
54
|
+
case 3:
|
|
55
|
+
marker.setPosition(event.geography);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
66
58
|
};
|
|
67
59
|
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
60
|
+
const onClick = () => {
|
|
61
|
+
if (status == 1) {
|
|
62
|
+
status = 2;
|
|
63
|
+
skip++;
|
|
64
|
+
point.coordinates = event.geography;
|
|
65
|
+
point.event.trigger("pointer-in");
|
|
66
|
+
}
|
|
74
67
|
};
|
|
75
68
|
|
|
76
|
-
if (point.coordinates) {
|
|
77
|
-
darwMarker({
|
|
78
|
-
position: new LbsAMap.LngLat(point.coordinates[0], point.coordinates[1]),
|
|
79
|
-
height: point.coordinates[2] ?? point.height,
|
|
80
|
-
});
|
|
81
|
-
} else {
|
|
82
|
-
viewer.on("click", eventMarker);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
69
|
const onUpdate = (e: Set<string>) => {
|
|
86
|
-
|
|
70
|
+
if (skip) {
|
|
71
|
+
skip--;
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
87
74
|
e.forEach((key) => {
|
|
88
75
|
switch (key) {
|
|
89
76
|
case "show":
|
|
@@ -110,40 +97,41 @@ export function drawPoint(map: AMap, point: Point<unknown>) {
|
|
|
110
97
|
}
|
|
111
98
|
break;
|
|
112
99
|
case "src":
|
|
113
|
-
|
|
100
|
+
setIcon();
|
|
114
101
|
break;
|
|
115
102
|
case "size":
|
|
116
|
-
|
|
103
|
+
setIcon();
|
|
117
104
|
break;
|
|
118
105
|
case "center":
|
|
119
106
|
marker.setAnchor(point.center);
|
|
120
107
|
break;
|
|
121
108
|
case "rotation":
|
|
122
|
-
marker.setAngle(point.rotation
|
|
109
|
+
marker.setAngle(point.rotation);
|
|
123
110
|
break;
|
|
124
111
|
default:
|
|
125
112
|
throw new Error(`${key} 还不支持修改`);
|
|
126
113
|
}
|
|
127
114
|
});
|
|
128
|
-
|
|
129
|
-
keys.forEach((e) => {
|
|
130
|
-
switch (e) {
|
|
131
|
-
case "icon":
|
|
132
|
-
marker.setIcon(
|
|
133
|
-
new LbsAMap.Icon({
|
|
134
|
-
image: point.src,
|
|
135
|
-
size: point.size,
|
|
136
|
-
imageSize: point.size,
|
|
137
|
-
}),
|
|
138
|
-
);
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
115
|
};
|
|
143
116
|
|
|
117
|
+
function setIcon() {
|
|
118
|
+
marker.setIcon(
|
|
119
|
+
new LbsAMap.Icon({
|
|
120
|
+
image: point.src,
|
|
121
|
+
size: point.size,
|
|
122
|
+
imageSize: point.size,
|
|
123
|
+
}),
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
144
127
|
const onDestroy = () => {
|
|
145
128
|
marker.remove();
|
|
146
129
|
point.event.off("update", onUpdate);
|
|
147
130
|
point.event.off("destroy", onDestroy);
|
|
148
131
|
};
|
|
132
|
+
|
|
133
|
+
event.on("pointer-move", onMouseMove);
|
|
134
|
+
event.on("left-click", onClick);
|
|
135
|
+
point.event.on("update", onUpdate);
|
|
136
|
+
point.event.on("destroy", onDestroy);
|
|
149
137
|
}
|