@hzab/map-combine 0.3.0-beta → 1.0.0-alpha.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/CHANGELOG.md +2 -0
- package/package.json +13 -4
- package/src/amap/AMap.ts +8 -3
- package/src/amap/AMapEvent.ts +8 -1
- package/src/amap/AMapPolygon.ts +195 -196
- package/src/amap/AMapPolyline.ts +185 -186
- package/src/basic/MapCombine.ts +2 -0
- package/src/basic/ReactPoint.tsx +363 -362
- package/src/cesium/CesiumEvent.ts +4 -0
- package/src/cesium/CesiumMap.ts +341 -342
- package/src/cesium/CesiumTile3D.ts +2 -6
- package/src/mine/MineEvent.ts +38 -25
package/src/amap/AMapPolyline.ts
CHANGED
|
@@ -1,186 +1,185 @@
|
|
|
1
|
-
import { AMap } from "./AMap";
|
|
2
|
-
import { Polyline } from "../basic/Polyline";
|
|
3
|
-
|
|
4
|
-
export function drawPolyline(map: AMap, polyline: Polyline<unknown>) {
|
|
5
|
-
const { event, viewer, LbsAMap } = map;
|
|
6
|
-
|
|
7
|
-
let status = 0;
|
|
8
|
-
let skip = 0;
|
|
9
|
-
let target = null;
|
|
10
|
-
let aMapPolylineEditor = null;
|
|
11
|
-
|
|
12
|
-
const _event = {
|
|
13
|
-
cursor: polyline.cursor,
|
|
14
|
-
silent: polyline.silent,
|
|
15
|
-
onPointerIn() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
aMapPolylineEditor.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
graphical.on("
|
|
45
|
-
graphical.on("
|
|
46
|
-
graphical.on("
|
|
47
|
-
graphical.on("
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
target
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
aMapPolylineEditor.
|
|
86
|
-
aMapPolylineEditor.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
target.
|
|
109
|
-
target.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
polyline.
|
|
144
|
-
polyline.event.trigger("
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
aMapPolylineEditor.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
aMapPolylineEditor.
|
|
173
|
-
|
|
174
|
-
event.off("
|
|
175
|
-
polyline.event.off("
|
|
176
|
-
polyline.event.off("
|
|
177
|
-
polyline.event.off("
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
event.on("
|
|
182
|
-
polyline.event.on("
|
|
183
|
-
polyline.event.on("
|
|
184
|
-
polyline.event.on("
|
|
185
|
-
|
|
186
|
-
}
|
|
1
|
+
import { AMap } from "./AMap";
|
|
2
|
+
import { Polyline } from "../basic/Polyline";
|
|
3
|
+
|
|
4
|
+
export function drawPolyline(map: AMap, polyline: Polyline<unknown>) {
|
|
5
|
+
const { event, viewer, LbsAMap } = map;
|
|
6
|
+
|
|
7
|
+
let status = 0;
|
|
8
|
+
let skip = 0;
|
|
9
|
+
let target = null;
|
|
10
|
+
let aMapPolylineEditor = null;
|
|
11
|
+
|
|
12
|
+
const _event = {
|
|
13
|
+
cursor: polyline.cursor,
|
|
14
|
+
silent: polyline.silent,
|
|
15
|
+
onPointerIn() {
|
|
16
|
+
status == 2 && polyline.event.trigger("pointer-in");
|
|
17
|
+
},
|
|
18
|
+
onPointerOut() {
|
|
19
|
+
status == 2 && polyline.event.trigger("pointer-out");
|
|
20
|
+
},
|
|
21
|
+
onLClick() {
|
|
22
|
+
status == 2 && polyline.event.trigger("left-click");
|
|
23
|
+
},
|
|
24
|
+
onRClick(e) {
|
|
25
|
+
event.canvas = [e.pixel.x, e.pixel.y];
|
|
26
|
+
if (polyline.menu) {
|
|
27
|
+
map.menu.show(polyline.menu);
|
|
28
|
+
}
|
|
29
|
+
status == 2 && polyline.event.trigger("right-click");
|
|
30
|
+
},
|
|
31
|
+
onDbClick() {
|
|
32
|
+
polyline.editable &&
|
|
33
|
+
status == 2 &&
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
aMapPolylineEditor.setTarget(target);
|
|
36
|
+
aMapPolylineEditor.open();
|
|
37
|
+
polyline.event.trigger("start-edit");
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const bindEvent = (graphical) => {
|
|
43
|
+
graphical.on("click", _event.onLClick);
|
|
44
|
+
graphical.on("rightclick", _event.onRClick);
|
|
45
|
+
graphical.on("dblclick", _event.onDbClick);
|
|
46
|
+
graphical.on("mouseover", _event.onPointerIn);
|
|
47
|
+
graphical.on("mouseout", _event.onPointerOut);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
aMapPolylineEditor = new LbsAMap.PolylineEditor(viewer, undefined, {
|
|
51
|
+
createOptions: {
|
|
52
|
+
strokeColor: polyline.stroke,
|
|
53
|
+
strokeWeight: polyline.lineWidth,
|
|
54
|
+
strokeStyle: polyline.dash ? "dashed" : "solid",
|
|
55
|
+
strokeDasharray: [10, 10],
|
|
56
|
+
},
|
|
57
|
+
editOptions: {
|
|
58
|
+
strokeColor: polyline.stroke,
|
|
59
|
+
strokeWeight: polyline.lineWidth,
|
|
60
|
+
strokeStyle: polyline.dash ? "dashed" : "solid",
|
|
61
|
+
strokeDasharray: [10, 10],
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
aMapPolylineEditor.on("add", (e) => {
|
|
66
|
+
status = 3;
|
|
67
|
+
target = e.target;
|
|
68
|
+
bindEvent(target);
|
|
69
|
+
// polygon.event.trigger("data-loaded");
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
if (polyline.coordinates) {
|
|
73
|
+
status = 2;
|
|
74
|
+
target = new LbsAMap.Polyline({
|
|
75
|
+
path: polyline.coordinates,
|
|
76
|
+
strokeColor: polyline.stroke,
|
|
77
|
+
strokeWeight: polyline.lineWidth,
|
|
78
|
+
strokeStyle: polyline.dash ? "dashed" : "solid",
|
|
79
|
+
strokeDasharray: [10, 10],
|
|
80
|
+
});
|
|
81
|
+
viewer.add(target);
|
|
82
|
+
bindEvent(target);
|
|
83
|
+
} else {
|
|
84
|
+
aMapPolylineEditor.close();
|
|
85
|
+
aMapPolylineEditor.setTarget();
|
|
86
|
+
aMapPolylineEditor.open();
|
|
87
|
+
}
|
|
88
|
+
const onUpdate = (e: Set<string>) => {
|
|
89
|
+
if (skip) {
|
|
90
|
+
skip--;
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
e.forEach((key) => {
|
|
95
|
+
switch (key) {
|
|
96
|
+
case "show":
|
|
97
|
+
if (polyline.show) {
|
|
98
|
+
target.show();
|
|
99
|
+
} else {
|
|
100
|
+
target.hide();
|
|
101
|
+
}
|
|
102
|
+
break;
|
|
103
|
+
case "editable":
|
|
104
|
+
break;
|
|
105
|
+
case "coordinates":
|
|
106
|
+
if (polyline.coordinates) {
|
|
107
|
+
target.setPath(polyline.coordinates);
|
|
108
|
+
target.setzIndex(polyline.coordinates[2]);
|
|
109
|
+
target.show();
|
|
110
|
+
status = 2;
|
|
111
|
+
} else {
|
|
112
|
+
target.hide();
|
|
113
|
+
status = 0;
|
|
114
|
+
}
|
|
115
|
+
break;
|
|
116
|
+
|
|
117
|
+
case "lineWidth":
|
|
118
|
+
target.setOptions({
|
|
119
|
+
strokeWeight: polyline.lineWidth,
|
|
120
|
+
});
|
|
121
|
+
break;
|
|
122
|
+
case "stroke":
|
|
123
|
+
target.setOptions({
|
|
124
|
+
strokeColor: polyline.stroke,
|
|
125
|
+
});
|
|
126
|
+
break;
|
|
127
|
+
case "dash":
|
|
128
|
+
target.setOptions({
|
|
129
|
+
strokeStyle: polyline.dash ? "dashed" : "solid",
|
|
130
|
+
});
|
|
131
|
+
break;
|
|
132
|
+
default:
|
|
133
|
+
throw new Error(`${key} 还不支持修改`);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
const onDbClick = () => {
|
|
138
|
+
switch (status) {
|
|
139
|
+
case 1:
|
|
140
|
+
status = 2;
|
|
141
|
+
skip++;
|
|
142
|
+
polyline.coordinates = target.getPath().map((item) => [item.lng, item.lat]);
|
|
143
|
+
polyline.event.trigger("data-loaded");
|
|
144
|
+
polyline.event.trigger("pointer-in");
|
|
145
|
+
break;
|
|
146
|
+
case 3:
|
|
147
|
+
polyline.event.trigger("stop-edit");
|
|
148
|
+
aMapPolylineEditor.setTarget();
|
|
149
|
+
aMapPolylineEditor.close();
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const onStartEdit = () => {
|
|
154
|
+
switch (status) {
|
|
155
|
+
case 2:
|
|
156
|
+
status = 3;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const onStopEdit = () => {
|
|
162
|
+
if (status == 3) {
|
|
163
|
+
status = 2;
|
|
164
|
+
skip++;
|
|
165
|
+
polyline.coordinates = target.getPath().map((item) => [item.lng, item.lat]);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const onDestroy = () => {
|
|
170
|
+
viewer.remove(target);
|
|
171
|
+
aMapPolylineEditor.close();
|
|
172
|
+
aMapPolylineEditor.setTarget();
|
|
173
|
+
event.off("double-click", onDbClick);
|
|
174
|
+
polyline.event.off("update", onUpdate);
|
|
175
|
+
polyline.event.off("start-edit", onStartEdit);
|
|
176
|
+
polyline.event.off("stop-edit", onStopEdit);
|
|
177
|
+
polyline.event.off("destroy", onDestroy);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
event.on("double-click", onDbClick);
|
|
181
|
+
polyline.event.on("update", onUpdate);
|
|
182
|
+
polyline.event.on("start-edit", onStartEdit);
|
|
183
|
+
polyline.event.on("stop-edit", onStopEdit);
|
|
184
|
+
polyline.event.on("destroy", onDestroy);
|
|
185
|
+
}
|
package/src/basic/MapCombine.ts
CHANGED