1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
| import * as turf from "@turf/turf";
| const msgList = {
| label: null,
| circle: undefined,
| line: [],
| startLine: [],
| backLine: [],
| point: null,
| removeLabel() {
| if (this.label) {
| this.label.removeFromMap();
| this.label = null;
| }
| if (this.circle) {
| this.circle.removeFromMap();
| this.circle = undefined;
| }
| if (this.pathLine) {
| Viewer.entities.remove(this.pathLine);
| this.pathLine = null;
| }
| this.startLine = [];
| this.line = [];
| this.backLine = [];
| },
| setInit(item) {
| const point = item.point.split(',');
| this.point = point;
| this.label = earthCtrl.factory.createLabel({
| lon: point[0],
| lat: point[1],
| alt: 40,
| text: item.msg,
| image: config.sdkImg + 'Workers/image/mark.png',
| // 文本偏移量
| pixelOffset: new SmartEarth.Cesium.Cartesian2(0, -50),
| // 图片偏移量
| iPixelOffset: new SmartEarth.Cesium.Cartesian2(0, -20),
| });
| this.showCircle(point, '#ff0000');
| if (!item.geom.line) return;
| this.line = this.chunkArray(item.geom.line, 2);
| var center_Coord = [];
|
| for (var i = 0; i < this.line.length; i++) {
| center_Coord.push(turf.point([this.line[i][0], this.line[i][1]]));
| var coord_start =this.getCartesianCoord(this.line[i][0], this.line[i][1], 1);
| this.startLine.push(coord_start);
| }
| var features = turf.featureCollection(center_Coord);
|
| var center = turf.center(features).geometry.coordinates;
|
| earthCtrl.camera.flyTo(center[0], center[1], 8000, 0, -90, 0, 0);
| var backGeom = this.line.reverse();
| for (var i = 0; i < backGeom.length; i++) {
| var coord_back =this.getCartesianCoord(backGeom[i][0], backGeom[i][1], 1);
| this.backLine.push(coord_back);
| }
| // this.$nextTick(() => {
|
| this.showPathLine(this.startLine, true);
| // });
| },
| getCartesianCoord(longitude, latitude, height) {
| return Cesium.Cartesian3.fromDegrees(longitude, latitude, height);
| },
| showCircle(res, color) {
| if (this.circle) {
| this.circle.removeFromMap();
| this.circle = undefined;
| }
| this.circle = earthCtrl.factory.createCircleScan({
| lon: res[0],
| lat: res[1],
| color: SmartEarth.Cesium.Color.fromCssColorString(color),
| height: 1,
| maxRadius: 100,
| duration: 5000,
| });
| },
| chunkArray(array, size) {
| return array.reduce((chunks, current, index) => {
| const chunkIndex = Math.floor(index / size);
|
| if (!chunks[chunkIndex]) {
| chunks[chunkIndex] = [];
| }
|
| chunks[chunkIndex].push(current);
|
| return chunks;
| }, []);
| },
| showPathLine(degreesArr, boolen) {
| this.pathLine = Viewer.entities.add({
| polyline: {
| clampToGround: true,
| //轨迹线的分布位置
| positions: degreesArr,
| material: new Cesium.ImageMaterialProperty({
| //图片的颜色
| //轨迹运行的速率
| speed: 10,
| //随意一张图片
| image: config.images + '向右.png',
| //将轨迹分成一行50个图片
| repeat: { x: 40, y: 1 },
| }),
| width: 20,
| },
| });
| },
| };
| export default msgList;
|
|