@mapgis/webclient-vue-cesium 16.0.13 → 16.0.14

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.
@@ -43,7 +43,8 @@
43
43
  "interpolationAlgorithm": "LagrangePolynomialApproximation",
44
44
  "isLoop": true,
45
45
  "showPath": true,
46
- "showInfo": true
46
+ "showInfo": true,
47
+ "modelUrl": ""
47
48
  }
48
49
  ```
49
50
 
@@ -61,6 +62,7 @@
61
62
  | isLoop | Boolean | 是否循环。 默认 true |
62
63
  | showPath | Boolean | 是否显示路径。默认 true |
63
64
  | showInfo | Boolean | 是否显示提示信息。默认 true |
65
+ | modelUrl | String | 模型资源路径。默认"",可通过配置界面设置 |
64
66
 
65
67
  ### `models`
66
68
 
@@ -187,7 +189,8 @@ export default {
187
189
  interpolationAlgorithm: "LagrangePolynomialApproximation",
188
190
  isLoop: true,
189
191
  showPath: true,
190
- showInfo: true
192
+ showInfo: true,
193
+ modelUrl: ""
191
194
  },
192
195
  models: [
193
196
  {
@@ -278,7 +281,8 @@ export default {
278
281
  interpolationAlgorithm: "LagrangePolynomialApproximation",
279
282
  isLoop: true,
280
283
  showPath: true,
281
- showInfo: true
284
+ showInfo: true,
285
+ modelUrl: ""
282
286
  },
283
287
  models: [
284
288
  {
@@ -35,7 +35,8 @@
35
35
  "interpolationAlgorithm": "LagrangePolynomialApproximation",
36
36
  "isLoop": true,
37
37
  "showPath": true,
38
- "showInfo": true
38
+ "showInfo": true,
39
+ "modelUrl": ""
39
40
  }
40
41
  ```
41
42
 
@@ -54,6 +55,7 @@
54
55
  | |
55
56
  | showPath | Boolean | 是否显示路径。默认 true |
56
57
  | showInfo | Boolean | 是否显示提示信息。默认 true |
58
+ | modelUrl | String | 模型资源路径。默认"",可通过配置界面设置 |
57
59
 
58
60
  ### `models`
59
61
 
@@ -174,7 +176,8 @@ export default {
174
176
  interpolationAlgorithm: "LagrangePolynomialApproximation",
175
177
  isLoop: true,
176
178
  showPath: true,
177
- showInfo: true
179
+ showInfo: true,
180
+ modelUrl: ""
178
181
  },
179
182
  models: [
180
183
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapgis/webclient-vue-cesium",
3
- "version": "16.0.13",
3
+ "version": "16.0.14",
4
4
  "description": "mapgis webclient-vue-cesium",
5
5
  "main": "dist-libs/webclient-vue-cesium.umd.min.js",
6
6
  "module1": "src/main.js",
@@ -30,7 +30,7 @@
30
30
  "@mapgis/webclient-es6-service": "16.0.3",
31
31
  "@mapgis/webclient-plot": "^16.0.0",
32
32
  "@mapgis/webclient-store": "^10.5.5",
33
- "@mapgis/webclient-vue-ui": "16.0.8",
33
+ "@mapgis/webclient-vue-ui": "16.0.9",
34
34
  "@turf/turf": "^5.1.6",
35
35
  "@vuepress/plugin-active-header-links": "^1.7.1",
36
36
  "@vuepress/plugin-nprogress": "^1.7.1",
@@ -697,6 +697,9 @@ export default {
697
697
  break;
698
698
  }
699
699
  }
700
+ },
701
+ $_stopDrawAll() {
702
+ this.$refs.graphicLayer.$_stopDrawAll();
700
703
  }
701
704
  }
702
705
  };
@@ -1334,8 +1334,10 @@ export default {
1334
1334
  }
1335
1335
  //设置当前绘制图标类型为鼠标选中
1336
1336
  this.currentIconType = "mouse";
1337
+
1338
+ let graphicJSON = this.$_getJsonById(json.id);
1337
1339
  //获取设置面板显示参数
1338
- this.editPanelValues = this.$_getEditPanelValuesFromJSON(json);
1340
+ this.editPanelValues = this.$_getEditPanelValuesFromJSON(graphicJSON);
1339
1341
  this.editPanelValues.showOutline = false;
1340
1342
  let graphic = this.$_getGraphicByID(json.id);
1341
1343
  if (graphic && graphic.heading) {
@@ -1346,10 +1348,8 @@ export default {
1346
1348
  roll: roll ? Math.PI / roll : 0
1347
1349
  };
1348
1350
  }
1349
- let graphicJSON = this.$_getJsonById(json.id);
1350
- this.$refs.editPanel.$_setEditPanelValues(
1351
- this.$_getEditPanelValuesFromJSON(graphicJSON)
1352
- );
1351
+ this.$refs.editPanel.$_setEditPanelValues(this.editPanelValues);
1352
+
1353
1353
  //定义视角高度
1354
1354
  const { style } = graphic;
1355
1355
  const { offsetHeight, extrudedHeight, radiusX, width, radius } = style;
@@ -1497,12 +1497,14 @@ export default {
1497
1497
  );
1498
1498
  break;
1499
1499
  case "model":
1500
+ position = graphic.positions[0];
1500
1501
  let Cartesian3 = new Cesium.Cartesian3(
1501
- json.positions[0],
1502
- json.positions[1],
1503
- json.positions[2]
1502
+ position.x,
1503
+ position.y,
1504
+ position.z
1504
1505
  );
1505
1506
  center = this.$_cartesian3ToLongLat(Cartesian3);
1507
+ this.destinationHeight += center.alt;
1506
1508
  destination = Cesium.Cartesian3.fromDegrees(
1507
1509
  center.lng,
1508
1510
  center.lat,
@@ -2038,37 +2040,35 @@ export default {
2038
2040
  const { Cesium, viewer } = this;
2039
2041
  const vm = this;
2040
2042
  if (
2041
- !this.transformEditor ||
2042
- this.transformEditor.id !== this.editPanelValues.id
2043
+ !window.transformEditor ||
2044
+ window.transformEditor.id !== this.editPanelValues.id
2043
2045
  ) {
2044
- //创建平移编辑器
2045
- this.transformEditor = new Cesium.ModelEditor({
2046
- container: viewer.container,
2047
- scene: viewer.scene,
2048
- transform: graphic.modelMatrix,
2049
- boundingSphere: graphic.boundingSphere,
2050
- getViewModel: function(e) {
2051
- if (graphic.type === "model") {
2052
- const { heading, pitch, roll } = e.headingPitchRoll;
2053
-
2054
- vm.editPanelValues.orientation = {
2055
- heading: heading ? Math.PI / heading : 0,
2056
- pitch: pitch ? Math.PI / pitch : 0,
2057
- roll: roll ? Math.PI / roll : 0
2058
- };
2059
- vm.editPanelValues.positions = vm.$_cartesian3ToLongLat(
2060
- e.position
2061
- );
2062
- vm.$refs.editPanel.$_setEditPanelValues(vm.editPanelValues);
2063
- }
2046
+ const { vueIndex, vueKey } = this;
2047
+ let graphicLayer = this.$_getGraphicLayer(vueIndex, vueKey);
2048
+ let getViewModel = function(e) {
2049
+ if (graphic.type === "model") {
2050
+ const { heading, pitch, roll } = e.headingPitchRoll;
2051
+ vm.editPanelValues.orientation = {
2052
+ heading: heading ? Math.PI / heading : 0,
2053
+ pitch: pitch ? Math.PI / pitch : 0,
2054
+ roll: roll ? Math.PI / roll : 0
2055
+ };
2056
+ vm.editPanelValues.positions = vm.$_cartesian3ToLongLat(e.position);
2057
+ vm.$refs.editPanel.isUpdatePanel = false;
2058
+ vm.$refs.editPanel.$_setEditPanelValues(vm.editPanelValues);
2064
2059
  }
2065
- });
2066
- this.transformEditor.id = this.editPanelValues.id;
2060
+ };
2061
+ //获取平移编辑器
2062
+ window.transformEditor = graphicLayer.getTransformEditor(
2063
+ graphic,
2064
+ getViewModel
2065
+ );
2066
+ window.transformEditor.id = this.editPanelValues.id;
2067
2067
  } else {
2068
- this.transformEditor.transform = graphic.modelMatrix;
2069
- this.transformEditor.boundingSphere = graphic.boundingSphere;
2068
+ window.transformEditor.transform = graphic.modelMatrix;
2069
+ window.transformEditor.boundingSphere = graphic.boundingSphere;
2070
2070
  }
2071
- return this.transformEditor;
2071
+ return window.transformEditor;
2072
2072
  },
2073
2073
  /**
2074
2074
  * 定位到模型
@@ -2089,7 +2089,8 @@ export default {
2089
2089
  json.positions[2]
2090
2090
  );
2091
2091
  const center = this.$_cartesian3ToLongLat(Cartesian3);
2092
- const destinationHeight = Number(graphic.boundingSphere.radius * 4);
2092
+ const destinationHeight =
2093
+ Number(graphic.boundingSphere.radius * 4) + center.alt;
2093
2094
  const destination = Cesium.Cartesian3.fromDegrees(
2094
2095
  center.lng,
2095
2096
  center.lat,
@@ -1145,19 +1145,19 @@ export default {
1145
1145
  }
1146
1146
  }
1147
1147
  },
1148
+ // 动态单体化下该方法执行后会导致模型大面积高亮,参考禅道bug2356
1148
1149
  restoreHighlight() {
1149
- const { g3dLayerIndex, viewer } = this;
1150
-
1151
- if (!(typeof g3dLayerIndex === "number") || g3dLayerIndex < 0) return;
1152
- let g3dLayer = viewer.scene.layers.getLayer(g3dLayerIndex);
1153
- let m3ds = g3dLayer.getM3DLayerIndexes();
1154
- m3ds.forEach(index => {
1155
- let m3d = g3dLayer.getLayer(index);
1156
- if (m3d) {
1157
- m3d.reset(); //该函数目前底层MapGISM3DSet.reset无效 后期记得修改
1158
- m3d.pickedOid = undefined;
1159
- }
1160
- });
1150
+ // const { g3dLayerIndex, viewer } = this;
1151
+ // if (!(typeof g3dLayerIndex === "number") || g3dLayerIndex < 0) return;
1152
+ // let g3dLayer = viewer.scene.layers.getLayer(g3dLayerIndex);
1153
+ // let m3ds = g3dLayer.getM3DLayerIndexes();
1154
+ // m3ds.forEach(index => {
1155
+ // let m3d = g3dLayer.getLayer(index);
1156
+ // if (m3d) {
1157
+ // m3d.reset(); //该函数目前底层MapGISM3DSet.reset无效 后期记得修改
1158
+ // m3d.pickedOid = undefined;
1159
+ // }
1160
+ // });
1161
1161
  },
1162
1162
  handleDynamicQuery() {
1163
1163
  this.featurevisible = false;
@@ -172,7 +172,8 @@ export default {
172
172
  interpolationAlgorithm: "LagrangePolynomialApproximation",
173
173
  isLoop: true,
174
174
  showPath: true,
175
- showInfo: true
175
+ showInfo: true,
176
+ modelUrl: ""
176
177
  };
177
178
  }
178
179
  },
@@ -200,7 +201,9 @@ export default {
200
201
  models: {
201
202
  handler() {
202
203
  if (this.models.length > 0 && this.models[0].value) {
203
- this.modelUrl = this.models[0].value;
204
+ if (this.modelUrl === "" || !this.models.includes(this.modelUrl)) {
205
+ this.modelUrl = this.models[0].value;
206
+ }
204
207
  } else {
205
208
  this.modelUrl = "";
206
209
  }
@@ -211,6 +214,11 @@ export default {
211
214
  setting: {
212
215
  handler() {
213
216
  this.settingCopy = JSON.parse(JSON.stringify(this.setting));
217
+ // 确保this.settingCopy.modelUrl非空
218
+ this.modelUrl =
219
+ this.settingCopy.modelUrl && this.settingCopy.modelUrl !== ""
220
+ ? this.settingCopy.modelUrl
221
+ : "";
214
222
  },
215
223
  immediate: true
216
224
  }
@@ -412,6 +420,7 @@ export default {
412
420
  },
413
421
  onModelChange(value) {
414
422
  window.SceneWanderManager.animation._modelUrl = value;
423
+ this.settingCopy.modelUrl = value;
415
424
  }
416
425
  }
417
426
  };
@@ -52,8 +52,40 @@
52
52
  }
53
53
  "
54
54
  >
55
- <template slot="position" slot-scope="text">
56
- <div class="path-position" :title="text">{{ text }}</div>
55
+ <!-- <template slot="position" slot-scope="text, record">
56
+ <mapgis-ui-input
57
+ v-if="record.editable"
58
+ :value="text"
59
+ @change="
60
+ e => handleChange(e.target.value, record.number, record)
61
+ "
62
+ />
63
+ <div v-else class="path-position" :title="text">{{ text }}</div>
64
+ </template> -->
65
+ <template
66
+ v-for="item in ['x', 'y', 'z']"
67
+ :slot="item"
68
+ slot-scope="text, record"
69
+ >
70
+ <mapgis-ui-input
71
+ v-if="record.editable"
72
+ :key="item"
73
+ :value="text"
74
+ @change="
75
+ e => handleChange(e.target.value, record.number, item)
76
+ "
77
+ />
78
+ <div v-else :key="item" class="path-position" :title="text">
79
+ {{ text }}
80
+ </div>
81
+ </template>
82
+ <template slot="operation" slot-scope="text, record">
83
+ <span v-if="record.editable"
84
+ ><a @click="savePosition(record.number)">保存</a></span
85
+ >
86
+ <span v-else
87
+ ><a @click="editPosition(record.number)">编辑</a></span
88
+ >
57
89
  </template>
58
90
  </mapgis-ui-table>
59
91
  <mapgis-ui-empty
@@ -138,7 +170,8 @@ export default {
138
170
  interpolationAlgorithm: "LagrangePolynomialApproximation",
139
171
  isLoop: true,
140
172
  showPath: true,
141
- showInfo: true
173
+ showInfo: true,
174
+ modelUrl: ""
142
175
  };
143
176
  }
144
177
  },
@@ -157,10 +190,15 @@ export default {
157
190
  pathTotal() {
158
191
  return `${this.pathsCopy.length}条路线`;
159
192
  },
160
- positions() {
161
- return this.addedPositions.map((position, index) => {
162
- return { number: index + 1, ...position };
163
- });
193
+ positions: {
194
+ get() {
195
+ return this.addedPositions.map((position, index) => {
196
+ return { number: index + 1, ...position };
197
+ });
198
+ },
199
+ set(val) {
200
+ this.addedPositions = [...val];
201
+ }
164
202
  }
165
203
  },
166
204
  watch: {
@@ -193,22 +231,29 @@ export default {
193
231
  dataIndex: "x",
194
232
  align: "center",
195
233
  ellipsis: true,
196
- scopedSlots: { customRender: "position" }
234
+ scopedSlots: { customRender: "x" }
197
235
  },
198
236
  {
199
237
  title: "纬度",
200
238
  dataIndex: "y",
201
239
  align: "center",
202
240
  ellipsis: true,
203
- scopedSlots: { customRender: "position" }
241
+ scopedSlots: { customRender: "y" }
204
242
  },
205
243
  {
206
244
  title: "高度",
207
245
  dataIndex: "z",
208
246
  align: "center",
209
247
  ellipsis: true,
210
- scopedSlots: { customRender: "position" },
248
+ scopedSlots: { customRender: "z" },
211
249
  width: 60
250
+ },
251
+ {
252
+ title: "操作",
253
+ dataIndex: "operation",
254
+ align: "center",
255
+ ellipsis: true,
256
+ scopedSlots: { customRender: "operation" }
212
257
  }
213
258
  ],
214
259
  pathsCopy: [],
@@ -216,7 +261,8 @@ export default {
216
261
  polyline: undefined,
217
262
  emptyImage: MapgisUiEmpty.PRESENTED_IMAGE_SIMPLE,
218
263
  emptyDescription: "暂无数据",
219
- lastClickLineId: undefined
264
+ lastClickLineId: undefined,
265
+ pointArr: [] // 存放新增路线时保存的点位信息
220
266
  };
221
267
  },
222
268
  created() {},
@@ -261,7 +307,7 @@ export default {
261
307
 
262
308
  this.draw.startDrawingMarker({
263
309
  material,
264
- addDefaultMark: true,
310
+ addDefaultMark: false,
265
311
  callback: coord => {
266
312
  // 获取当前坐标系标准
267
313
  const ellipsoid = vm.viewer.scene.globe.ellipsoid;
@@ -299,6 +345,9 @@ export default {
299
345
  }
300
346
  });
301
347
  }
348
+
349
+ // 绘制点 根据linePoints的内容进行绘制点
350
+ vm.drawPoint(true);
302
351
  }
303
352
  });
304
353
  },
@@ -351,7 +400,8 @@ export default {
351
400
  interpolationAlgorithm,
352
401
  isLoop,
353
402
  showPath,
354
- showInfo
403
+ showInfo,
404
+ modelUrl: ""
355
405
  }
356
406
  };
357
407
  this.pathsCopy.push(path);
@@ -406,6 +456,14 @@ export default {
406
456
  this.polyline = undefined;
407
457
  }
408
458
  },
459
+ removePoint() {
460
+ if (this.pointArr && this.pointArr.length > 0) {
461
+ this.pointArr.forEach(item => {
462
+ this.viewer.entities.remove(item);
463
+ });
464
+ this.pointArr = [];
465
+ }
466
+ },
409
467
  showRoad() {
410
468
  this.removeRoad();
411
469
  this.polyline = this.viewer.entities.add({
@@ -421,8 +479,53 @@ export default {
421
479
  });
422
480
  this.viewer.flyTo(this.polyline);
423
481
  },
482
+ drawPoint(flag) {
483
+ // flag为true表示不需要重新绘制全部点(正常绘制路线),反之则为修改路线的点位,需要重新绘制点位
484
+ if (flag) {
485
+ // 取linePoints最后三位
486
+ const drawArr = [
487
+ this.linePoints[this.linePoints.length - 3],
488
+ this.linePoints[this.linePoints.length - 2],
489
+ this.linePoints[this.linePoints.length - 1]
490
+ ];
491
+ const point = this.viewer.entities.add({
492
+ position: this.Cesium.Cartesian3.fromDegrees(
493
+ drawArr[0],
494
+ drawArr[1],
495
+ drawArr[2]
496
+ ),
497
+ point: {
498
+ pixelSize: 10,
499
+ color: this.Cesium.Color.RED
500
+ }
501
+ });
502
+ this.pointArr.push(point);
503
+ } else {
504
+ this.removePoint();
505
+ for (let i = 0; i < this.linePoints.length - 1; i += 3) {
506
+ const drawArr = [
507
+ this.linePoints[i],
508
+ this.linePoints[i + 1],
509
+ this.linePoints[i + 2]
510
+ ];
511
+ const point = this.viewer.entities.add({
512
+ position: this.Cesium.Cartesian3.fromDegrees(
513
+ drawArr[0],
514
+ drawArr[1],
515
+ drawArr[2]
516
+ ),
517
+ point: {
518
+ pixelSize: 10,
519
+ color: this.Cesium.Color.RED
520
+ }
521
+ });
522
+ this.pointArr.push(point);
523
+ }
524
+ }
525
+ },
424
526
  _stopAdded() {
425
527
  this.removeRoad();
528
+ this.removePoint();
426
529
  if (this.draw) {
427
530
  this.draw.stopDrawing();
428
531
  }
@@ -439,6 +542,54 @@ export default {
439
542
  },
440
543
  _savePaths() {
441
544
  this.$emit("save-paths", this.pathsCopy);
545
+ },
546
+ savePosition(index) {
547
+ const newData = [...this.positions];
548
+ const target = newData.find(item => index === item.number);
549
+ if (target) {
550
+ delete target.editable;
551
+ this.positions = newData;
552
+ }
553
+ this.resizeRoaming();
554
+ },
555
+ editPosition(index) {
556
+ const newData = [...this.positions];
557
+ const currentKey = newData.find(item => item.number === index);
558
+ currentKey.editable = true;
559
+ this.positions = newData;
560
+ },
561
+ handleChange(value, index, column) {
562
+ const newData = [...this.positions];
563
+ const target = newData.find(item => index === item.number);
564
+ if (target) {
565
+ target[column] = value;
566
+ this.positions = newData;
567
+ }
568
+ },
569
+ // 重新绘制路线
570
+ resizeRoaming() {
571
+ this.linePoints = [];
572
+ this.addedPositions.forEach(item => {
573
+ this.linePoints.push(item.x);
574
+ this.linePoints.push(item.y);
575
+ this.linePoints.push(item.z);
576
+ });
577
+ if (this.addedPositions.length > 1) {
578
+ this.removeRoad();
579
+
580
+ this.polyline = this.viewer.entities.add({
581
+ name: "scence-roaming",
582
+ polyline: {
583
+ positions: this.Cesium.Cartesian3.fromDegreesArrayHeights(
584
+ this.linePoints
585
+ ),
586
+ width: 2,
587
+ material: this.Cesium.Color.RED,
588
+ clampToGround: false
589
+ }
590
+ });
591
+ }
592
+ this.drawPoint();
442
593
  }
443
594
  }
444
595
  };