@go-home-early/go-home-early98 0.3.1 → 0.3.2

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.

Potentially problematic release.


This version of @go-home-early/go-home-early98 might be problematic. Click here for more details.

Files changed (56) hide show
  1. package/README.md +28 -16
  2. package/dist/go-home-early.umd.js +5 -5
  3. package/package.json +2 -16
  4. package/src/packages/Cesium/DrawMap/DrawJs/CesiumEntityEdit.js +427 -0
  5. package/src/packages/Cesium/DrawMap/DrawJs/CreatePolygonOnGround.js +202 -0
  6. package/src/packages/Cesium/DrawMap/DrawJs/DrawAttackArrow.js +477 -0
  7. package/src/packages/Cesium/DrawMap/DrawJs/DrawBillboard.js +114 -0
  8. package/src/packages/Cesium/DrawMap/DrawJs/DrawCircle.js +311 -0
  9. package/src/packages/Cesium/DrawMap/DrawJs/DrawCircleTY.js +237 -0
  10. package/src/packages/Cesium/DrawMap/DrawJs/DrawCurve.js +256 -0
  11. package/src/packages/Cesium/DrawMap/DrawJs/DrawPincerArrow.js +584 -0
  12. package/src/packages/Cesium/DrawMap/DrawJs/DrawPoint.js +158 -0
  13. package/src/packages/Cesium/DrawMap/DrawJs/DrawPolygon.js +215 -0
  14. package/src/packages/Cesium/DrawMap/DrawJs/DrawPolyline.js +213 -0
  15. package/src/packages/Cesium/DrawMap/DrawJs/DrawPolylineJT.js +218 -0
  16. package/src/packages/Cesium/DrawMap/DrawJs/DrawProFile.js +314 -0
  17. package/src/packages/Cesium/DrawMap/DrawJs/DrawRectangle.js +215 -0
  18. package/src/packages/Cesium/DrawMap/DrawJs/DrawstraightArrow.js +364 -0
  19. package/src/packages/Cesium/DrawMap/DrawJs/MeasurePolygon.js +337 -0
  20. package/src/packages/Cesium/DrawMap/DrawJs/MeasurePolyline.js +285 -0
  21. package/src/packages/Cesium/DrawMap/DrawJs/ReminderTip.js +78 -0
  22. package/src/packages/Cesium/DrawMap/DrawJs/SlopeAspect.js +436 -0
  23. package/src/packages/Cesium/DrawMap/DrawJs/measureLength.js +177 -0
  24. package/src/packages/Cesium/DrawMap/index.vue +272 -0
  25. package/src/packages/Cesium/components/LocationDialog.vue +283 -0
  26. package/src/packages/Cesium/components/Popup.vue +591 -0
  27. package/src/packages/Cesium/components/PoumianDialog.vue +200 -0
  28. package/src/packages/Cesium/imgs/add-off.png +0 -0
  29. package/src/packages/Cesium/imgs/add.png +0 -0
  30. package/src/packages/Cesium/imgs/circle.png +0 -0
  31. package/src/packages/Cesium/imgs/icon-position-blue.png +0 -0
  32. package/src/packages/Cesium/imgs/line.png +0 -0
  33. package/src/packages/Cesium/imgs/map-delete.png +0 -0
  34. package/src/packages/Cesium/imgs/map.png +0 -0
  35. package/src/packages/Cesium/imgs/orientation-bg.svg +14 -0
  36. package/src/packages/Cesium/imgs/orientation.svg +21 -0
  37. package/src/packages/Cesium/imgs/poi.png +0 -0
  38. package/src/packages/Cesium/imgs/point.png +0 -0
  39. package/src/packages/Cesium/imgs/polygon.png +0 -0
  40. package/src/packages/Cesium/imgs/popup/back-popup-img.png +0 -0
  41. package/src/packages/Cesium/imgs/popup/backimg-btn.png +0 -0
  42. package/src/packages/Cesium/imgs/popup/dialog-bd.png +0 -0
  43. package/src/packages/Cesium/imgs/popup/dialog-btn.png +0 -0
  44. package/src/packages/Cesium/imgs/popup/dialog-ft.png +0 -0
  45. package/src/packages/Cesium/imgs/popup/dialog-hd.png +0 -0
  46. package/src/packages/Cesium/imgs/reduce-off.png +0 -0
  47. package/src/packages/Cesium/index.md +292 -0
  48. package/src/packages/Cesium/index.vue +3830 -0
  49. package/src/packages/Cesium/materials/CircularDiffusionMaterialProperty.js +98 -0
  50. package/src/packages/Cesium/materials/CircularRippleMaterialProperty.js +126 -0
  51. package/src/packages/Cesium/materials/PolylineArrowMaterialProperty.js +109 -0
  52. package/src/packages/Cesium/utils/MeasureHeight.js +261 -0
  53. package/src/packages/Cesium/utils/MeasureTools.js +1188 -0
  54. package/src/packages/index.js +33 -0
  55. package/src/packages/utils/charts.js +54 -0
  56. package/src/packages/utils/index.js +50 -0
@@ -0,0 +1,158 @@
1
+ // DrawPoint
2
+ /*
3
+ 绘制点
4
+ */
5
+ import imgUrl from '../../imgs/icon-position-blue.png';
6
+ class DrawPoint {
7
+ constructor(arg) {
8
+ this.viewer = arg.viewer;
9
+ this.Cesium = arg.Cesium;
10
+ this.Text = arg.data.text || '';
11
+ this.Color = arg.data.color || '#000';
12
+ this.imgUrl = arg.data.imgUrl || '';
13
+ this.FontSize = arg.data.fontSize || 16;
14
+ this.callback = arg.data.callback || null;
15
+ this.pxNum = arg.data.pxNum || 5;
16
+ this.handler = null;
17
+ this._point = null; // 最后一个点
18
+ this._pointData = null; // 点数据用于构造点
19
+ this._entities = []; // 脏数据
20
+ }
21
+
22
+ // 返回最后活动点
23
+ get point() {
24
+ return this._point;
25
+ }
26
+
27
+ // 加载点
28
+ loadPoint(data) {
29
+ return this.createPoint(data);
30
+ }
31
+
32
+ // 返回点数据用于加载点
33
+ getData() {
34
+ return this._pointData;
35
+ }
36
+
37
+ // 开始绘制
38
+ startCreate() {
39
+ var $this = this;
40
+ this.handler = new this.Cesium.ScreenSpaceEventHandler(
41
+ this.viewer.scene.canvas
42
+ );
43
+ this.handler.setInputAction(function(evt) {
44
+ // 单机开始绘制
45
+ var cartesian = $this.getCatesian3FromPX(evt.position);
46
+ if (!cartesian) return;
47
+ var point = $this.createPoint(cartesian);
48
+ $this._pointData = cartesian;
49
+ $this._point = point;
50
+ if (typeof $this.callback == 'function') {
51
+ // 将坐标点转换为经纬度坐标
52
+ // 获取实体点的坐标
53
+ var pointData = point.position.getValue($this.Cesium.JulianDate.now());
54
+ var cartographic = $this.Cesium.Cartographic.fromCartesian(pointData);
55
+
56
+ var longitude = $this.Cesium.Math.toDegrees(cartographic.longitude);
57
+ var latitude = $this.Cesium.Math.toDegrees(cartographic.latitude);
58
+
59
+ // 创建包含图片的 GeoJSON 对象
60
+ var geojson = {
61
+ type: 'Feature',
62
+ geometry: {
63
+ type: 'Point',
64
+ coordinates: [longitude, latitude]
65
+ },
66
+ properties: {
67
+ name: 'My Image',
68
+ imageUrl:
69
+ 'https://img2.baidu.com/it/u=1022682943,197734876&fm=253&fmt=auto&app=138&f=GIF?w=956&h=500',
70
+ text: $this.Text,
71
+ fontSize: $this.FontSize,
72
+ color: $this.Color
73
+ }
74
+ };
75
+ $this.callback(geojson);
76
+ }
77
+ // $this.handler.destroy();
78
+ }, $this.Cesium.ScreenSpaceEventType.LEFT_CLICK);
79
+ }
80
+
81
+ // 创建点击删除事件
82
+ creatDeleteClick(isSelect) {
83
+ const $this = this;
84
+ if (isSelect) {
85
+ this.handler = new this.Cesium.ScreenSpaceEventHandler(
86
+ $this.viewer.scene.canvas
87
+ );
88
+ this.handler.setInputAction(function(movement) {
89
+ var pick = $this.viewer.scene.pick(movement.position, 3, 3);
90
+
91
+ if (!pick) {
92
+ return;
93
+ }
94
+ $this.viewer.entities.removeById(pick.id._id);
95
+ }, $this.Cesium.ScreenSpaceEventType.LEFT_CLICK);
96
+ } else {
97
+ this.handler.destroy();
98
+ this.handler = null;
99
+ }
100
+ }
101
+
102
+ // 创建点
103
+ createPoint(cartesian) {
104
+ var $this = this;
105
+ var point = this.viewer.entities.add({
106
+ position: cartesian,
107
+ billboard: {
108
+ image:
109
+ 'https://img2.baidu.com/it/u=1022682943,197734876&fm=253&fmt=auto&app=138&f=GIF?w=956&h=500',
110
+ heightReference: $this.Cesium.HeightReference.CLAMP_TO_GROUND,
111
+ horizontalOrigin: $this.Cesium.HorizontalOrigin.MID, // 原点X轴位置 MID
112
+ verticalOrigin: $this.Cesium.VerticalOrigin.BOTTOM, // 原点Y轴位置 BOTTOM
113
+ scale: 0.07, // 尺寸大小
114
+ disableDepthTestDistance: Number.POSITIVE_INFINITY // 数值无限大 不会被地形遮挡
115
+ },
116
+ label: {
117
+ pixelOffset: new $this.Cesium.Cartesian2(0, -45),
118
+ horizontalOrigin: $this.Cesium.HorizontalOrigin.CENTER,
119
+ verticalOrigin: $this.Cesium.VerticalOrigin.BOTTOM,
120
+ text: $this.Text,
121
+ scale: 1,
122
+ fillColor: $this.Cesium.Color.fromCssColorString($this.Color),
123
+ font: `normal ${$this.FontSize}px MicroSoft YaHei`,
124
+ disableDepthTestDistance: Number.POSITIVE_INFINITY,
125
+ heightReference: $this.Cesium.HeightReference.CLAMP_TO_GROUND
126
+ }
127
+ });
128
+ $this._entities.push(point); // 加载脏数据
129
+ return point;
130
+ }
131
+
132
+ // 销毁鼠标事件
133
+ destroy() {
134
+ if (this.handler) {
135
+ this.handler.destroy();
136
+ this.handler = null;
137
+ }
138
+ }
139
+
140
+ // 清空实体对象
141
+ clear() {
142
+ for (var i = 0; i < this._entities.length; i++) {
143
+ this.viewer.entities.remove(this._entities[i]);
144
+ }
145
+ this._entities = [];
146
+ this._point = null;
147
+ }
148
+
149
+ getCatesian3FromPX(px) {
150
+ var cartesian;
151
+ var ray = this.viewer.camera.getPickRay(px);
152
+ if (!ray) return null;
153
+ cartesian = this.viewer.scene.globe.pick(ray, this.viewer.scene);
154
+ return cartesian;
155
+ }
156
+ }
157
+
158
+ export default DrawPoint;
@@ -0,0 +1,215 @@
1
+ // DrawPolygon
2
+ /*
3
+ 绘制面
4
+ */
5
+ class DrawPolygon {
6
+ constructor(arg) {
7
+ // 写在这个里面实例化后不会相等不影响
8
+ this.drawName = 'DrawPolygon';
9
+ this.viewer = arg.viewer;
10
+ this.Cesium = arg.Cesium;
11
+ this.Text = arg.data.text || '';
12
+ this.Color = arg.data.color || '#000';
13
+ this.imgUrl = arg.data.imgUrl || '';
14
+ this.FontSize = arg.data.fontSize || 16;
15
+ this.callback = arg.data.callback || null;
16
+ this.pxNum = arg.data.pxNum || 5;
17
+ this.handler = null;
18
+ this._polygon = null; // 活动面
19
+ this._polygonLast = null; // 最后一个面
20
+ this._positions = []; // 活动点
21
+ this._entities_point = []; // 脏数据
22
+ this._entities_polygon = []; // 脏数据
23
+ this._polygonData = null; // 用户构造面
24
+ }
25
+
26
+ // 返回最后活动面
27
+ get polygon() {
28
+ return this._polygonLast;
29
+ }
30
+
31
+ // 修改样式
32
+ updateStyleFunction(data) {
33
+ this.Text = data.text || '';
34
+ this.Color = data.color || '#000';
35
+ this.imgUrl = data.imgUrl || '';
36
+ this.FontSize = data.fontSize || 16;
37
+ this.callback = data.callback || null;
38
+ }
39
+
40
+ // 返回面数据用于加载面
41
+ getData() {
42
+ return this._polygonData;
43
+ }
44
+
45
+ // 加载面
46
+ loadPolygon(data) {
47
+ var $this = this;
48
+ for (var i = 0; i < $this._entities_point.length; i++) {
49
+ $this.viewer.entities.remove($this._entities_point[i]);
50
+ }
51
+ return this.viewer.entities.add({
52
+ // id: 'DrawPolygon' + new Date().getTime() + Math.random(),
53
+ // id: 'DrawPolygon' + $this.viewer.entities.values.length + 1,
54
+ polygon: {
55
+ hierarchy: new $this.Cesium.PolygonHierarchy(data),
56
+ clampToGround: true,
57
+ show: true,
58
+ fill: true,
59
+ material: $this.Cesium.Color.fromCssColorString($this.Color),
60
+ width: 3
61
+ // zIndex: $this.viewer.entities.values.length + 1
62
+ // outlineColor: Cesium.Color.RED,
63
+ // outlineWidth: 10,
64
+ // outline: true
65
+ }
66
+ });
67
+ }
68
+
69
+ // 开始绘制
70
+ startCreate() {
71
+ var $this = this;
72
+ this.handler = new this.Cesium.ScreenSpaceEventHandler(
73
+ this.viewer.scene.canvas
74
+ );
75
+ this.handler.setInputAction(function(evt) {
76
+ // 单机开始绘制
77
+ var cartesian = $this.getCatesian3FromPX(evt.position);
78
+ if ($this._positions.length == 0) {
79
+ $this._positions.push(cartesian.clone());
80
+ }
81
+ $this.createPoint(cartesian);
82
+ $this._positions.push(cartesian);
83
+ }, $this.Cesium.ScreenSpaceEventType.LEFT_CLICK);
84
+
85
+ this.handler.setInputAction(function(evt) {
86
+ // 移动时绘制面
87
+ if ($this._positions.length < 1) return;
88
+ var cartesian = $this.getCatesian3FromPX(evt.endPosition);
89
+ if ($this._positions.length == 3) {
90
+ if (!$this.Cesium.defined($this._polygon)) {
91
+ $this._polygon = $this.createPolygon();
92
+ }
93
+ }
94
+ $this._positions.pop();
95
+ $this._positions.push(cartesian);
96
+ }, $this.Cesium.ScreenSpaceEventType.MOUSE_MOVE);
97
+
98
+ this.handler.setInputAction(function(evt) {
99
+ if (!$this._polygon) return;
100
+ var cartesian = $this.getCatesian3FromPX(evt.position);
101
+ $this._positions.pop();
102
+ $this._positions.push(cartesian);
103
+ $this.createPoint(cartesian);
104
+ $this._polygonData = $this._positions.concat();
105
+ console.log(`output->$this._polygonData`, $this._polygonData);
106
+ $this.viewer.entities.remove($this._positions); // 移除
107
+ $this._positions = null;
108
+ $this._positions = [];
109
+ var Polygon = $this.loadPolygon($this._polygonData);
110
+ $this._entities_polygon.push(Polygon);
111
+ $this._polygonLast = Polygon;
112
+ if (typeof $this.callback == 'function') {
113
+ // 提取多边形层次结构
114
+ var hierarchy = Polygon.polygon.hierarchy.getValue();
115
+ console.log(`output->hierarchy`, hierarchy);
116
+ // 从层次结构中提取坐标
117
+ var coordinates = hierarchy.positions.map(function(position) {
118
+ var cartographic = $this.Cesium.Cartographic.fromCartesian(position);
119
+ return [
120
+ $this.Cesium.Math.toDegrees(cartographic.longitude),
121
+ $this.Cesium.Math.toDegrees(cartographic.latitude)
122
+ ];
123
+ });
124
+
125
+ // 创建GeoJSON对象
126
+ var geojson = {
127
+ type: 'Polygon',
128
+ coordinates: [coordinates],
129
+ // coordinates: hierarchy.positions,
130
+ geometry: {
131
+ type: 'Polygon'
132
+ },
133
+ properties: {
134
+ color: $this.Color
135
+ }
136
+ };
137
+
138
+ $this.callback(geojson);
139
+ // $this.callback(JSON.stringify(geojson));
140
+ }
141
+ // $this.handler.destroy();
142
+ }, $this.Cesium.ScreenSpaceEventType.RIGHT_CLICK);
143
+ }
144
+
145
+ // 创建面
146
+ createPolygon() {
147
+ var $this = this;
148
+ var polygon = this.viewer.entities.add({
149
+ // id: '777777777777777777' + new Date().getTime() + Math.random(),
150
+ polygon: {
151
+ hierarchy: new $this.Cesium.CallbackProperty(function() {
152
+ return new $this.Cesium.PolygonHierarchy($this._positions);
153
+ }, false),
154
+ clampToGround: true,
155
+ show: true,
156
+ fill: true,
157
+ material: $this.Cesium.Color.fromCssColorString('#fff').withAlpha(0.5),
158
+ width: 3,
159
+ outlineColor: $this.Cesium.Color.BLACK,
160
+ outlineWidth: 1,
161
+ outline: false
162
+ }
163
+ });
164
+ $this._entities_polygon.push(polygon);
165
+ return polygon;
166
+ }
167
+
168
+ // 创建点
169
+ createPoint(cartesian) {
170
+ var $this = this;
171
+ var point = this.viewer.entities.add({
172
+ position: cartesian,
173
+ point: {
174
+ pixelSize: 10,
175
+ color: $this.Cesium.Color.YELLOW
176
+ }
177
+ });
178
+ $this._entities_point.push(point);
179
+ return point;
180
+ }
181
+
182
+ // 销毁事件
183
+ destroy() {
184
+ if (this.handler) {
185
+ this.handler.destroy();
186
+ this.handler = null;
187
+ }
188
+ }
189
+
190
+ // 清空实体对象
191
+ clear() {
192
+ for (let i = 0; i < this._entities_point.length; i++) {
193
+ this.viewer.entities.remove(this._entities_point[i]);
194
+ }
195
+ for (let i = 0; i < this._entities_polygon.length; i++) {
196
+ this.viewer.entities.remove(this._entities_polygon[i]);
197
+ }
198
+ this._polygon = null; // 活动面
199
+ this._polygonLast = null; // 最后一个面
200
+ this._positions = []; // 活动点
201
+ this._entities_point = []; // 脏数据
202
+ this._entities_polygon = []; // 脏数据
203
+ this._polygonData = null; // 用户构造面
204
+ }
205
+
206
+ getCatesian3FromPX(px) {
207
+ var cartesian;
208
+ var ray = this.viewer.camera.getPickRay(px);
209
+ if (!ray) return null;
210
+ cartesian = this.viewer.scene.globe.pick(ray, this.viewer.scene);
211
+ return cartesian;
212
+ }
213
+ }
214
+
215
+ export default DrawPolygon;
@@ -0,0 +1,213 @@
1
+ // DrawPolyline
2
+ /*
3
+ 绘制线
4
+ */
5
+ import * as turf from '@turf/turf';
6
+
7
+ class DrawPolyline {
8
+ constructor(arg) {
9
+ this.viewer = arg.viewer;
10
+ this.Cesium = arg.Cesium;
11
+ this.Text = arg.data.text || '';
12
+ this.Color = arg.data.color || '#000';
13
+ this.imgUrl = arg.data.imgUrl || '';
14
+ this.FontSize = arg.data.fontSize || 16;
15
+ this.callback = arg.data.callback || null;
16
+ this.pxNum = arg.data.pxNum || 5;
17
+ this.handler = null;
18
+ this._polyline = null; // 活动线
19
+ this._polylineLast = null; // 最后一条线
20
+ this._positions = []; // 活动点
21
+ this._entities_point = []; // 脏数据
22
+ this._entities_line = []; // 脏数据
23
+ this._polylineData = null; // 用于构造线数据
24
+ }
25
+
26
+ // 返回最后活动线
27
+ get line() {
28
+ return this._polylineLast;
29
+ }
30
+
31
+ // 返回线数据用于加载线
32
+ getData() {
33
+ return this._polylineData;
34
+ }
35
+
36
+ // 加载线
37
+ loadPolyline(data) {
38
+ var $this = this;
39
+ for (var i = 0; i < $this._entities_point.length; i++) {
40
+ $this.viewer.entities.remove($this._entities_point[i]);
41
+ }
42
+ var polyline = this.viewer.entities.add({
43
+ polyline: {
44
+ positions: data,
45
+ show: true,
46
+ material: $this.Cesium.Color.fromCssColorString($this.Color),
47
+ width: $this.pxNum,
48
+ clampToGround: true
49
+ }
50
+ });
51
+ return polyline;
52
+ }
53
+
54
+ // 开始创建
55
+ startCreate() {
56
+ var $this = this;
57
+ this.handler = new this.Cesium.ScreenSpaceEventHandler(
58
+ this.viewer.scene.canvas
59
+ );
60
+ this.handler.setInputAction(function(evt) {
61
+ // 单机开始绘制
62
+ // 屏幕坐标转地形上坐标
63
+ var cartesian = $this.getCatesian3FromPX(evt.position);
64
+ if ($this._positions.length == 0) {
65
+ $this._positions.push(cartesian.clone());
66
+ }
67
+ $this._positions.push(cartesian);
68
+ $this.createPoint(cartesian); // 绘制点
69
+ }, $this.Cesium.ScreenSpaceEventType.LEFT_CLICK);
70
+ this.handler.setInputAction(function(evt) {
71
+ // 移动时绘制线
72
+ if ($this._positions.length < 1) return;
73
+ var cartesian = $this.getCatesian3FromPX(evt.endPosition);
74
+ if (!$this.Cesium.defined($this._polyline)) {
75
+ $this._polyline = $this.createPolyline();
76
+ }
77
+ if ($this._polyline) {
78
+ $this._positions.pop();
79
+ $this._positions.push(cartesian);
80
+ }
81
+ }, $this.Cesium.ScreenSpaceEventType.MOUSE_MOVE);
82
+ this.handler.setInputAction(function(evt) {
83
+ if (!$this._polyline) return;
84
+ var cartesian = $this.getCatesian3FromPX(evt.position);
85
+ $this._positions.pop();
86
+ $this._positions.push(cartesian);
87
+ $this.createPoint(cartesian); // 绘制点
88
+ $this._polylineData = $this._positions.concat();
89
+ $this.viewer.entities.remove($this._polyline); // 移除
90
+ $this._polyline = null;
91
+ $this._positions = [];
92
+ var line = $this.loadPolyline($this._polylineData); // 加载线
93
+ $this._entities_line.push(line);
94
+ $this._polylineLast = line;
95
+ if (typeof $this.callback == 'function') {
96
+ // 提取多边形层次结构
97
+ var hierarchy = line.polyline.positions.getValue();
98
+ // 从层次结构中提取坐标
99
+ var coordinates = hierarchy.map(function(position) {
100
+ var cartographic = $this.Cesium.Cartographic.fromCartesian(position);
101
+ return [
102
+ $this.Cesium.Math.toDegrees(cartographic.longitude),
103
+ $this.Cesium.Math.toDegrees(cartographic.latitude)
104
+ ];
105
+ });
106
+
107
+ // 创建GeoJSON对象
108
+ var geojson = {
109
+ type: 'LineString',
110
+ coordinates: coordinates,
111
+ geometry: {
112
+ type: 'LineString'
113
+ },
114
+ properties: {
115
+ color: $this.Color,
116
+ width: $this.pxNum
117
+ }
118
+ };
119
+ $this.callback(geojson);
120
+ }
121
+ // $this.handler.destroy();
122
+ }, $this.Cesium.ScreenSpaceEventType.RIGHT_CLICK);
123
+ }
124
+
125
+ // 创建点击删除事件
126
+ creatDeleteClick(isSelect) {
127
+ const $this = this;
128
+ if (isSelect) {
129
+ this.handler = new this.Cesium.ScreenSpaceEventHandler(
130
+ $this.viewer.scene.canvas
131
+ );
132
+ this.handler.setInputAction(function(movement) {
133
+ var pick = $this.viewer.scene.pick(movement.position, 3, 3);
134
+
135
+ if (!pick) {
136
+ return;
137
+ }
138
+ $this.viewer.entities.removeById(pick.id._id);
139
+ }, $this.Cesium.ScreenSpaceEventType.LEFT_CLICK);
140
+ } else {
141
+ this.handler.destroy();
142
+ this.handler = null;
143
+ }
144
+ }
145
+
146
+ // 创建点
147
+ createPoint(cartesian) {
148
+ var $this = this;
149
+ var point = this.viewer.entities.add({
150
+ position: cartesian,
151
+ point: {
152
+ pixelSize: 10,
153
+ color: $this.Cesium.Color.YELLOW
154
+ }
155
+ });
156
+ $this._entities_point.push(point);
157
+ return point;
158
+ }
159
+
160
+ // 创建线
161
+ createPolyline() {
162
+ var $this = this;
163
+ var polyline = this.viewer.entities.add({
164
+ polyline: {
165
+ // 使用cesium的peoperty
166
+ positions: new $this.Cesium.CallbackProperty(function() {
167
+ return $this._positions;
168
+ }, false),
169
+ show: true,
170
+ material:
171
+ $this.Cesium.Color.fromCssColorString('#ffffff').withAlpha(0.5),
172
+ width: $this.pxNum,
173
+ clampToGround: true
174
+ }
175
+ });
176
+ $this._entities_line.push(polyline);
177
+ return polyline;
178
+ }
179
+
180
+ // 销毁
181
+ destroy() {
182
+ if (this.handler) {
183
+ this.handler.destroy();
184
+ this.handler = null;
185
+ }
186
+ }
187
+
188
+ // 清空实体对象
189
+ clear() {
190
+ for (let i = 0; i < this._entities_point.length; i++) {
191
+ this.viewer.entities.remove(this._entities_point[i]);
192
+ }
193
+ for (let i = 0; i < this._entities_line.length; i++) {
194
+ this.viewer.entities.remove(this._entities_line[i]);
195
+ }
196
+ this._polyline = null;
197
+ this._positions = [];
198
+ this._entities_point = []; // 脏数据
199
+ this._entities_line = []; // 脏数据
200
+ this._polylineData = null; // 用于构造线数据
201
+ this._polylineLast = null;
202
+ }
203
+
204
+ getCatesian3FromPX(px) {
205
+ var cartesian;
206
+ var ray = this.viewer.camera.getPickRay(px);
207
+ if (!ray) return null;
208
+ cartesian = this.viewer.scene.globe.pick(ray, this.viewer.scene);
209
+ return cartesian;
210
+ }
211
+ }
212
+
213
+ export default DrawPolyline;