@hzab/map-combine 0.2.2 → 0.2.3
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 +4 -0
- package/package.json +1 -1
- package/src/cesium/CesiumPolyline.ts +189 -202
- package/src/openlayer/OpenlayerPoint.ts +5 -5
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,115 +1,110 @@
|
|
|
1
1
|
import { Polyline } from "../basic/Polyline";
|
|
2
2
|
import { ChainNode, PolylineEditor } from "../utils/PolylineEditor";
|
|
3
3
|
import { CesiumMap } from "./CesiumMap";
|
|
4
|
-
import iconPoint from
|
|
5
|
-
import iconAdd from
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import iconPoint from "../assets/point.png";
|
|
5
|
+
import iconAdd from "../assets/add.png";
|
|
8
6
|
|
|
9
7
|
const source = `
|
|
10
8
|
czm_material czm_getMaterial(czm_materialInput materialInput){
|
|
11
9
|
czm_material material = czm_getDefaultMaterial(materialInput);
|
|
12
|
-
vec2 st =vec2(fract(materialInput.st.x*k), materialInput.st.y);
|
|
13
|
-
vec4 colorImage = texture2D(image, vec2(fract((st.s - speed*czm_frameNumber*0.005)), st.t));
|
|
14
|
-
|
|
15
|
-
material.diffuse =
|
|
10
|
+
vec2 st = vec2(fract(materialInput.st.x * k), materialInput.st.y);
|
|
11
|
+
vec4 colorImage = texture2D(image, vec2(fract((st.s - speed * czm_frameNumber * 0.005)), st.t));
|
|
12
|
+
vec3 tintedColor = color.rgb;
|
|
13
|
+
material.diffuse = tintedColor;
|
|
14
|
+
material.alpha = colorImage.a * color.a;
|
|
16
15
|
return material;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
}`;
|
|
20
17
|
function createLineMaterial(e: Polyline<unknown>) {
|
|
21
|
-
|
|
22
18
|
if (e.icon || e.flow) {
|
|
23
19
|
const material = new Cesium.Material({
|
|
24
20
|
fabric: {
|
|
25
|
-
type:
|
|
21
|
+
type: "PolylineFlowIcon",
|
|
26
22
|
uniforms: {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
color: Cesium.Color.fromCssColorString(e.stroke),
|
|
24
|
+
image:
|
|
25
|
+
e.icon ||
|
|
26
|
+
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIQAAABQCAYAAADY692eAAAACXBIWXMAACxLAAAsSwGlPZapAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAL7SURBVHgB7ZjBbRpBFIZnB4mzS4ALiGM6SDqJK0g6iNxBUoHTSdKBj0hwgBJ8RgI8Y3mtAQye2X2r1b73/QcjvLv+bOnXP5+pVqvVv+Px+NVl5nA4fFssFv+dUOD3yz+P3+/39+H1OfsB7x83m82dEwr8fvkXPz+0bRte/xQ8M9ntdj+dUOD3yz+Pj1/G4/Hv8LIteO7HcrmcOKHA75ef5rUQ0+n0OZxN9wXP3Y1Go0cnFPj98tNU6RsED8H06RsED8E8KQSCh2D6828geLb5F4VA8Gzzq2sXEDybfH/tAoJnk3+1EAieTb6/dRHBs8e/WQgEzx6/yrkJwbPD9zk3IXh2+FmFQPDs8LMKEYPg2eBnFwLBs8HPkso0CJ5ufvZC1EHwdPOLC4Hg6eYXFyIGwdPLb1QIBE8vv1gq0yB4+viNFqIOgqeP36oQCJ4+fqtCxCB4uvitC4Hg6eK3kso0CJ4OfuuFqIPg6eCLFQLB08EXK0QMgjd8vmghELzh88WkMg2CN1y+6ELUQfCGy++kEAjecPmdHBkxsXEB8hRhmY/E8+/L2x8Dvyd+JwsRg+ANk99ZIWICYOLKsnWCgV/O77QQwXR/ldwfZOjBCQZ+Ob+zQqzX6/jLTHLvD/P2IHV+wm/O70Qq46df4V+ZTcEj2/l8PnVCgd+c38lChLOraKpiO51g4Dfniy9E+JTsezi7sm25qqq/s9msxIbhd8gXXwhEbth80UIgcsPnix0ZiJwOvthCIHI6+CILgcjp4YssBCKnh9+6EIicLn6rIwOR08dvtRCInD5+44VA5HTyGy8EIqeT36gQiJxefvGRgcjp5hcvBCKnm1+0EIicfn7RQiBy+vnZhUDkbPCzjgxEzg4/ayEQOTv8TxcCkbPF/3QhEDlb/JuFQOTs8a8eGYicTf7VhUDkbPI/XAhEzi7/w4VA5OzyLwqByNnmnxwZiJxtfszJQiBytvkx7wuByNnm13lfCETONr/OayEQOdv8NBUih0im8YgcIpnmBTnnQRKFAYSqAAAAAElFTkSuQmCC",
|
|
27
|
+
speed: 1,
|
|
28
|
+
k: 20,
|
|
30
29
|
},
|
|
31
30
|
source,
|
|
32
31
|
},
|
|
33
32
|
translucent() {
|
|
34
|
-
return true
|
|
35
|
-
}
|
|
36
|
-
})
|
|
37
|
-
return material
|
|
33
|
+
return true;
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
return material;
|
|
38
37
|
} else {
|
|
39
38
|
return e.dash
|
|
40
39
|
? Cesium.Material.fromType("PolylineDash", {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
color: Cesium.Color.fromCssColorString(e.stroke),
|
|
41
|
+
dashLength: 10,
|
|
42
|
+
})
|
|
44
43
|
: Cesium.Material.fromType("Color", {
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
color: Cesium.Color.fromCssColorString(e.stroke),
|
|
45
|
+
});
|
|
47
46
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
47
|
}
|
|
52
48
|
|
|
53
49
|
function cartesian3Tgeography(e: any): number[] {
|
|
54
|
-
const r = Cesium.Cartographic.fromCartesian(e)
|
|
55
|
-
return [Cesium.Math.toDegrees(r.longitude), Cesium.Math.toDegrees(r.latitude), r.height]
|
|
50
|
+
const r = Cesium.Cartographic.fromCartesian(e);
|
|
51
|
+
return [Cesium.Math.toDegrees(r.longitude), Cesium.Math.toDegrees(r.latitude), r.height];
|
|
56
52
|
}
|
|
57
53
|
|
|
58
54
|
function geographyTcartesian3(e: number[]) {
|
|
59
|
-
return Cesium.Cartesian3.fromDegrees(e[0], e[1], e[2])
|
|
55
|
+
return Cesium.Cartesian3.fromDegrees(e[0], e[1], e[2]);
|
|
60
56
|
}
|
|
61
57
|
|
|
62
|
-
const eyeOffset = new Cesium.Cartesian3(0, 0, -1)
|
|
58
|
+
const eyeOffset = new Cesium.Cartesian3(0, 0, -1);
|
|
63
59
|
|
|
64
60
|
export function drawPolyline(map: CesiumMap, polyline: Polyline<unknown>) {
|
|
65
|
-
const { event, viewer } = map
|
|
66
|
-
let status = 0
|
|
67
|
-
let skip = 0
|
|
68
|
-
|
|
61
|
+
const { event, viewer } = map;
|
|
62
|
+
let status = 0;
|
|
63
|
+
let skip = 0;
|
|
69
64
|
|
|
70
|
-
let material = createLineMaterial(polyline)
|
|
65
|
+
let material = createLineMaterial(polyline);
|
|
71
66
|
const appearance = new Cesium.PolylineMaterialAppearance({
|
|
72
67
|
material,
|
|
73
|
-
})
|
|
68
|
+
});
|
|
74
69
|
const markers = viewer.scene.primitives.add(
|
|
75
70
|
new Cesium.BillboardCollection({
|
|
76
|
-
show: polyline.show
|
|
77
|
-
})
|
|
71
|
+
show: polyline.show,
|
|
72
|
+
}),
|
|
78
73
|
);
|
|
79
74
|
|
|
80
75
|
const _event = {
|
|
81
76
|
cursor: polyline.cursor,
|
|
82
77
|
silent: polyline.silent,
|
|
83
78
|
onPointerIn() {
|
|
84
|
-
status == 2 && polyline.event.trigger(
|
|
79
|
+
status == 2 && polyline.event.trigger("pointer-in");
|
|
85
80
|
},
|
|
86
81
|
onPointerOut() {
|
|
87
|
-
status == 2 && polyline.event.trigger(
|
|
82
|
+
status == 2 && polyline.event.trigger("pointer-out");
|
|
88
83
|
},
|
|
89
84
|
onLClick() {
|
|
90
|
-
status == 2 && polyline.event.trigger(
|
|
85
|
+
status == 2 && polyline.event.trigger("left-click");
|
|
91
86
|
},
|
|
92
87
|
onRClick() {
|
|
93
88
|
if (polyline.menu) {
|
|
94
89
|
map.menu.show(polyline.menu);
|
|
95
90
|
}
|
|
96
|
-
status == 2 && polyline.event.trigger(
|
|
91
|
+
status == 2 && polyline.event.trigger("right-click");
|
|
97
92
|
},
|
|
98
93
|
onDbClick() {
|
|
99
|
-
polyline.editable &&
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
94
|
+
polyline.editable &&
|
|
95
|
+
status == 2 &&
|
|
96
|
+
setTimeout(() => {
|
|
97
|
+
polyline.event.trigger("start-edit");
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
};
|
|
104
101
|
|
|
105
|
-
let primitive: any
|
|
106
|
-
let cache: any[]
|
|
107
|
-
let activeNode: ChainNode<any, any
|
|
102
|
+
let primitive: any;
|
|
103
|
+
let cache: any[];
|
|
104
|
+
let activeNode: ChainNode<any, any>;
|
|
108
105
|
if (polyline.coordinates) {
|
|
109
|
-
status = 2
|
|
110
|
-
cache = polyline.coordinates.map((e) =>
|
|
111
|
-
Cesium.Cartesian3.fromDegrees(e[0], e[1], e[2])
|
|
112
|
-
)
|
|
106
|
+
status = 2;
|
|
107
|
+
cache = polyline.coordinates.map((e) => Cesium.Cartesian3.fromDegrees(e[0], e[1], e[2]));
|
|
113
108
|
primitive = new Cesium.Primitive({
|
|
114
109
|
show: polyline.show,
|
|
115
110
|
geometryInstances: new Cesium.GeometryInstance({
|
|
@@ -121,17 +116,14 @@ export function drawPolyline(map: CesiumMap, polyline: Polyline<unknown>) {
|
|
|
121
116
|
id: _event,
|
|
122
117
|
}),
|
|
123
118
|
appearance,
|
|
124
|
-
|
|
125
119
|
});
|
|
126
120
|
viewer.scene.primitives.add(primitive);
|
|
127
121
|
}
|
|
128
122
|
|
|
123
|
+
const editor = new PolylineEditor<any, any>();
|
|
129
124
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
editor.on('create-node', (n) => {
|
|
134
|
-
if (n.type == 'node') {
|
|
125
|
+
editor.on("create-node", (n) => {
|
|
126
|
+
if (n.type == "node") {
|
|
135
127
|
const feature = markers.add({
|
|
136
128
|
position: new Cesium.Cartesian3(...n.position),
|
|
137
129
|
width: 16,
|
|
@@ -139,28 +131,27 @@ export function drawPolyline(map: CesiumMap, polyline: Polyline<unknown>) {
|
|
|
139
131
|
image: iconPoint,
|
|
140
132
|
eyeOffset,
|
|
141
133
|
id: {
|
|
142
|
-
cursor:
|
|
134
|
+
cursor: "move",
|
|
143
135
|
onPointerDown() {
|
|
144
|
-
status = 4
|
|
145
|
-
activeNode = n
|
|
146
|
-
map.moveable = false
|
|
136
|
+
status = 4;
|
|
137
|
+
activeNode = n;
|
|
138
|
+
map.moveable = false;
|
|
147
139
|
},
|
|
148
140
|
onPointerUp() {
|
|
149
141
|
if (status == 4) {
|
|
150
|
-
status = 3
|
|
151
|
-
map.moveable = true
|
|
152
|
-
activeNode = undefined
|
|
142
|
+
status = 3;
|
|
143
|
+
map.moveable = true;
|
|
144
|
+
activeNode = undefined;
|
|
153
145
|
}
|
|
154
146
|
},
|
|
155
147
|
onDbClick() {
|
|
156
|
-
n.destroy()
|
|
157
|
-
cache = editor.getCoordinates().map(e => new Cesium.Cartesian3(...e))
|
|
158
|
-
initPrimitive()
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
n.shape = feature
|
|
148
|
+
n.destroy();
|
|
149
|
+
cache = editor.getCoordinates().map((e) => new Cesium.Cartesian3(...e));
|
|
150
|
+
initPrimitive();
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
n.shape = feature;
|
|
164
155
|
} else {
|
|
165
156
|
const feature = markers.add({
|
|
166
157
|
position: new Cesium.Cartesian3(...n.position),
|
|
@@ -169,146 +160,146 @@ export function drawPolyline(map: CesiumMap, polyline: Polyline<unknown>) {
|
|
|
169
160
|
image: iconAdd,
|
|
170
161
|
eyeOffset,
|
|
171
162
|
id: {
|
|
172
|
-
cursor:
|
|
163
|
+
cursor: "pointer",
|
|
173
164
|
onPointerDown() {
|
|
174
|
-
status = 4
|
|
175
|
-
activeNode = n.insert()
|
|
176
|
-
map.cursor =
|
|
177
|
-
map.moveable = false
|
|
165
|
+
status = 4;
|
|
166
|
+
activeNode = n.insert();
|
|
167
|
+
map.cursor = "move";
|
|
168
|
+
map.moveable = false;
|
|
178
169
|
},
|
|
179
|
-
}
|
|
180
|
-
})
|
|
181
|
-
n.shape = feature
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
n.shape = feature;
|
|
182
173
|
}
|
|
183
|
-
})
|
|
184
|
-
|
|
185
|
-
editor.on(
|
|
186
|
-
n.shape.position = new Cesium.Cartesian3(...n.position)
|
|
187
|
-
})
|
|
188
|
-
editor.on(
|
|
189
|
-
markers.remove(n.shape)
|
|
190
|
-
})
|
|
191
|
-
editor.on(
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
editor.on("update-node", (n) => {
|
|
177
|
+
n.shape.position = new Cesium.Cartesian3(...n.position);
|
|
178
|
+
});
|
|
179
|
+
editor.on("remove-node", (n) => {
|
|
180
|
+
markers.remove(n.shape);
|
|
181
|
+
});
|
|
182
|
+
editor.on("empty", () => {
|
|
192
183
|
// markers.removeAll()
|
|
193
184
|
viewer.scene.primitives.remove(primitive);
|
|
194
|
-
status = 0
|
|
195
|
-
})
|
|
185
|
+
status = 0;
|
|
186
|
+
});
|
|
196
187
|
|
|
197
188
|
const onUpdate = (e: Set<string>) => {
|
|
198
189
|
if (skip) {
|
|
199
|
-
skip
|
|
200
|
-
return
|
|
190
|
+
skip--;
|
|
191
|
+
return;
|
|
201
192
|
}
|
|
202
|
-
const keys = new Set()
|
|
203
|
-
e.forEach(key => {
|
|
193
|
+
const keys = new Set();
|
|
194
|
+
e.forEach((key) => {
|
|
204
195
|
switch (key) {
|
|
205
|
-
case
|
|
196
|
+
case "show":
|
|
206
197
|
if (primitive) {
|
|
207
|
-
primitive.show = polyline.show
|
|
208
|
-
markers.show = polyline.show
|
|
198
|
+
primitive.show = polyline.show;
|
|
199
|
+
markers.show = polyline.show;
|
|
209
200
|
}
|
|
210
201
|
break;
|
|
211
|
-
case
|
|
202
|
+
case "editable":
|
|
212
203
|
break;
|
|
213
|
-
case
|
|
214
|
-
keys.add(
|
|
204
|
+
case "coordinates":
|
|
205
|
+
keys.add("Primitive");
|
|
215
206
|
break;
|
|
216
|
-
case
|
|
217
|
-
keys.add(
|
|
207
|
+
case "lineWidth":
|
|
208
|
+
keys.add("Primitive");
|
|
218
209
|
break;
|
|
219
|
-
case
|
|
220
|
-
keys.add(
|
|
210
|
+
case "icon":
|
|
211
|
+
keys.add("Material");
|
|
221
212
|
break;
|
|
222
|
-
case
|
|
223
|
-
keys.add(
|
|
213
|
+
case "flow":
|
|
214
|
+
keys.add("Material");
|
|
224
215
|
break;
|
|
225
|
-
case
|
|
216
|
+
case "stroke":
|
|
226
217
|
material.uniforms.color = Cesium.Color.fromCssColorString(polyline.stroke);
|
|
227
218
|
break;
|
|
228
|
-
case
|
|
229
|
-
keys.add(
|
|
219
|
+
case "dash":
|
|
220
|
+
keys.add("Material");
|
|
230
221
|
|
|
231
222
|
break;
|
|
232
223
|
default:
|
|
233
|
-
throw new Error(`${key} 还不支持修改`)
|
|
224
|
+
throw new Error(`${key} 还不支持修改`);
|
|
234
225
|
}
|
|
235
|
-
})
|
|
236
|
-
keys.forEach(key => {
|
|
226
|
+
});
|
|
227
|
+
keys.forEach((key) => {
|
|
237
228
|
switch (key) {
|
|
238
|
-
case
|
|
229
|
+
case "Primitive":
|
|
239
230
|
if (polyline.coordinates) {
|
|
240
|
-
cache = polyline.coordinates.map(e => geographyTcartesian3(e))
|
|
231
|
+
cache = polyline.coordinates.map((e) => geographyTcartesian3(e));
|
|
241
232
|
} else {
|
|
242
|
-
cache = []
|
|
243
|
-
markers.removeAll()
|
|
244
|
-
status = 0
|
|
233
|
+
cache = [];
|
|
234
|
+
markers.removeAll();
|
|
235
|
+
status = 0;
|
|
245
236
|
}
|
|
246
237
|
|
|
247
|
-
initPrimitive()
|
|
238
|
+
initPrimitive();
|
|
248
239
|
|
|
249
240
|
break;
|
|
250
|
-
case
|
|
251
|
-
material = createLineMaterial(polyline)
|
|
252
|
-
appearance.material = material
|
|
253
|
-
break
|
|
241
|
+
case "Material":
|
|
242
|
+
material = createLineMaterial(polyline);
|
|
243
|
+
appearance.material = material;
|
|
244
|
+
break;
|
|
254
245
|
}
|
|
255
|
-
})
|
|
256
|
-
}
|
|
246
|
+
});
|
|
247
|
+
};
|
|
257
248
|
|
|
258
249
|
const onStartEdit = () => {
|
|
259
|
-
|
|
260
250
|
switch (status) {
|
|
261
251
|
case 2:
|
|
262
|
-
status = 3
|
|
263
|
-
editor.setCoordinates(cache.map(e => [e.x, e.y, e.z]))
|
|
264
|
-
break
|
|
252
|
+
status = 3;
|
|
253
|
+
editor.setCoordinates(cache.map((e) => [e.x, e.y, e.z]));
|
|
254
|
+
break;
|
|
265
255
|
}
|
|
266
|
-
}
|
|
267
|
-
let temp: any
|
|
256
|
+
};
|
|
257
|
+
let temp: any;
|
|
268
258
|
const onMouseMove = () => {
|
|
269
|
-
const e = event.geography
|
|
259
|
+
const e = event.geography;
|
|
270
260
|
|
|
271
261
|
switch (status) {
|
|
272
262
|
case 1:
|
|
273
|
-
cache.pop()
|
|
274
|
-
cache.push(Cesium.Cartesian3.fromDegrees(e[0], e[1], e[2]))
|
|
275
|
-
initPrimitive()
|
|
276
|
-
break
|
|
263
|
+
cache.pop();
|
|
264
|
+
cache.push(Cesium.Cartesian3.fromDegrees(e[0], e[1], e[2]));
|
|
265
|
+
initPrimitive();
|
|
266
|
+
break;
|
|
277
267
|
case 4:
|
|
278
|
-
temp = Cesium.Cartesian3.fromDegrees(e[0], e[1], e[2])
|
|
279
|
-
activeNode.update([temp.x, temp.y, temp.z])
|
|
280
|
-
cache = editor.getCoordinates().map(e => new Cesium.Cartesian3(...e))
|
|
281
|
-
initPrimitive()
|
|
268
|
+
temp = Cesium.Cartesian3.fromDegrees(e[0], e[1], e[2]);
|
|
269
|
+
activeNode.update([temp.x, temp.y, temp.z]);
|
|
270
|
+
cache = editor.getCoordinates().map((e) => new Cesium.Cartesian3(...e));
|
|
271
|
+
initPrimitive();
|
|
282
272
|
break;
|
|
283
273
|
}
|
|
284
|
-
}
|
|
274
|
+
};
|
|
285
275
|
|
|
286
276
|
const onClick = () => {
|
|
287
|
-
const e = event.geography
|
|
277
|
+
const e = event.geography;
|
|
288
278
|
switch (status) {
|
|
289
279
|
case 0:
|
|
290
|
-
status = 1
|
|
291
|
-
cache = [Cesium.Cartesian3.fromDegrees(e[0], e[1], e[2])]
|
|
292
|
-
cache.push(cache[0])
|
|
293
|
-
initPrimitive()
|
|
280
|
+
status = 1;
|
|
281
|
+
cache = [Cesium.Cartesian3.fromDegrees(e[0], e[1], e[2])];
|
|
282
|
+
cache.push(cache[0]);
|
|
283
|
+
initPrimitive();
|
|
294
284
|
break;
|
|
295
285
|
case 1:
|
|
296
|
-
cache.push(cache[cache.length - 1])
|
|
286
|
+
cache.push(cache[cache.length - 1]);
|
|
297
287
|
// geometry.setCoordinates(cache)
|
|
298
|
-
initPrimitive()
|
|
299
|
-
break
|
|
288
|
+
initPrimitive();
|
|
289
|
+
break;
|
|
300
290
|
}
|
|
301
|
-
}
|
|
302
|
-
|
|
291
|
+
};
|
|
303
292
|
|
|
304
293
|
const initPrimitive = () => {
|
|
305
294
|
primitive && viewer.scene.primitives.remove(primitive);
|
|
306
295
|
if (cache.length > 1) {
|
|
307
|
-
const geometry = Cesium.PolylineGeometry.createGeometry(
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
296
|
+
const geometry = Cesium.PolylineGeometry.createGeometry(
|
|
297
|
+
new Cesium.PolylineGeometry({
|
|
298
|
+
positions: cache,
|
|
299
|
+
width: polyline.lineWidth,
|
|
300
|
+
vertexFormat: Cesium.PolylineMaterialAppearance.VERTEX_FORMAT,
|
|
301
|
+
}),
|
|
302
|
+
);
|
|
312
303
|
if (geometry) {
|
|
313
304
|
primitive = new Cesium.Primitive({
|
|
314
305
|
show: polyline.show,
|
|
@@ -321,62 +312,58 @@ export function drawPolyline(map: CesiumMap, polyline: Polyline<unknown>) {
|
|
|
321
312
|
});
|
|
322
313
|
viewer.scene.primitives.add(primitive);
|
|
323
314
|
} else {
|
|
324
|
-
primitive = undefined
|
|
315
|
+
primitive = undefined;
|
|
325
316
|
}
|
|
326
|
-
|
|
327
317
|
} else {
|
|
328
|
-
primitive = undefined
|
|
318
|
+
primitive = undefined;
|
|
329
319
|
}
|
|
330
|
-
|
|
331
|
-
}
|
|
320
|
+
};
|
|
332
321
|
|
|
333
322
|
const onDbClick = () => {
|
|
334
323
|
switch (status) {
|
|
335
324
|
case 1:
|
|
336
|
-
status = 2
|
|
337
|
-
skip
|
|
338
|
-
cache.pop()
|
|
339
|
-
cache.pop()
|
|
325
|
+
status = 2;
|
|
326
|
+
skip++;
|
|
327
|
+
cache.pop();
|
|
328
|
+
cache.pop();
|
|
340
329
|
// geometry.setCoordinates(cache)
|
|
341
|
-
polyline.coordinates = cache.map(e => cartesian3Tgeography(e))
|
|
342
|
-
polyline.event.trigger(
|
|
343
|
-
polyline.event.trigger(
|
|
344
|
-
break
|
|
330
|
+
polyline.coordinates = cache.map((e) => cartesian3Tgeography(e));
|
|
331
|
+
polyline.event.trigger("data-loaded");
|
|
332
|
+
polyline.event.trigger("pointer-in");
|
|
333
|
+
break;
|
|
345
334
|
case 3:
|
|
346
|
-
polyline.stopEdit()
|
|
347
|
-
break
|
|
335
|
+
polyline.stopEdit();
|
|
336
|
+
break;
|
|
348
337
|
}
|
|
349
|
-
}
|
|
338
|
+
};
|
|
350
339
|
|
|
351
340
|
const onStopEdit = () => {
|
|
352
341
|
if (status == 3) {
|
|
353
|
-
status = 2
|
|
354
|
-
skip
|
|
355
|
-
polyline.coordinates = editor.getCoordinates().map(e => cartesian3Tgeography(e))
|
|
356
|
-
editor.setCoordinates([])
|
|
357
|
-
polyline.event.trigger(
|
|
342
|
+
status = 2;
|
|
343
|
+
skip++;
|
|
344
|
+
polyline.coordinates = editor.getCoordinates().map((e) => cartesian3Tgeography(e));
|
|
345
|
+
editor.setCoordinates([]);
|
|
346
|
+
polyline.event.trigger("pointer-in");
|
|
358
347
|
}
|
|
359
|
-
}
|
|
348
|
+
};
|
|
360
349
|
|
|
361
350
|
const onDestroy = () => {
|
|
362
351
|
primitive && viewer.scene.primitives.remove(primitive);
|
|
363
|
-
viewer.scene.primitives.remove(markers)
|
|
364
|
-
event.off(
|
|
365
|
-
event.off(
|
|
366
|
-
event.off(
|
|
367
|
-
polyline.event.off(
|
|
368
|
-
polyline.event.off(
|
|
369
|
-
polyline.event.off(
|
|
370
|
-
polyline.event.off(
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
event.on(
|
|
375
|
-
event.on(
|
|
376
|
-
event.on(
|
|
377
|
-
polyline.event.on(
|
|
378
|
-
polyline.event.on(
|
|
379
|
-
polyline.event.on(
|
|
380
|
-
polyline.event.on('destroy', onDestroy)
|
|
381
|
-
|
|
352
|
+
viewer.scene.primitives.remove(markers);
|
|
353
|
+
event.off("pointer-move", onMouseMove);
|
|
354
|
+
event.off("left-click", onClick);
|
|
355
|
+
event.off("double-click", onDbClick);
|
|
356
|
+
polyline.event.off("update", onUpdate);
|
|
357
|
+
polyline.event.off("start-edit", onStartEdit);
|
|
358
|
+
polyline.event.off("stop-edit", onStopEdit);
|
|
359
|
+
polyline.event.off("destroy", onDestroy);
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
event.on("pointer-move", onMouseMove);
|
|
363
|
+
event.on("left-click", onClick);
|
|
364
|
+
event.on("double-click", onDbClick);
|
|
365
|
+
polyline.event.on("update", onUpdate);
|
|
366
|
+
polyline.event.on("start-edit", onStartEdit);
|
|
367
|
+
polyline.event.on("stop-edit", onStopEdit);
|
|
368
|
+
polyline.event.on("destroy", onDestroy);
|
|
382
369
|
}
|
|
@@ -9,7 +9,7 @@ import VectorLayer from "ol/layer/Vector";
|
|
|
9
9
|
const RD = 0.017453292519943295
|
|
10
10
|
|
|
11
11
|
export function drawPoint(map: OpenlayerMap, point: Point<unknown>) {
|
|
12
|
-
const { viewer, event, getFromLonLat } = map
|
|
12
|
+
const { viewer, event, getFromLonLat, isFromLonLat } = map
|
|
13
13
|
let status = 0
|
|
14
14
|
|
|
15
15
|
const source = new VectorSource();
|
|
@@ -67,7 +67,7 @@ export function drawPoint(map: OpenlayerMap, point: Point<unknown>) {
|
|
|
67
67
|
feature.set('event', _event, true)
|
|
68
68
|
if (point.coordinates) {
|
|
69
69
|
status = 2
|
|
70
|
-
geometry.setCoordinates(getFromLonLat(point.coordinates))
|
|
70
|
+
geometry.setCoordinates(getFromLonLat(point.coordinates, isFromLonLat))
|
|
71
71
|
layer.setZIndex(point.coordinates[2] ?? 1)
|
|
72
72
|
point.event.trigger('data-loaded')
|
|
73
73
|
source.addFeature(feature)
|
|
@@ -87,7 +87,7 @@ export function drawPoint(map: OpenlayerMap, point: Point<unknown>) {
|
|
|
87
87
|
break;
|
|
88
88
|
case 'coordinates':
|
|
89
89
|
if (point.coordinates) {
|
|
90
|
-
geometry.setCoordinates(getFromLonLat(point.coordinates))
|
|
90
|
+
geometry.setCoordinates(getFromLonLat(point.coordinates, isFromLonLat))
|
|
91
91
|
layer.setZIndex(point.coordinates[2])
|
|
92
92
|
switch (status) {
|
|
93
93
|
case 0:
|
|
@@ -142,12 +142,12 @@ export function drawPoint(map: OpenlayerMap, point: Point<unknown>) {
|
|
|
142
142
|
switch (status) {
|
|
143
143
|
case 0:
|
|
144
144
|
status = 1
|
|
145
|
-
geometry.setCoordinates(getFromLonLat(coordinates))
|
|
145
|
+
geometry.setCoordinates(getFromLonLat(coordinates, isFromLonLat))
|
|
146
146
|
source.addFeature(feature)
|
|
147
147
|
break;
|
|
148
148
|
case 1:
|
|
149
149
|
case 3:
|
|
150
|
-
geometry.setCoordinates(getFromLonLat(coordinates))
|
|
150
|
+
geometry.setCoordinates(getFromLonLat(coordinates, isFromLonLat))
|
|
151
151
|
break
|
|
152
152
|
}
|
|
153
153
|
}
|