支持删除 合并处理 点击合并后禁止键盘事件 排除继续监听事件重新组合数组
| | |
| | | grouped[index][type] = item.position; |
| | | } |
| | | }) |
| | | console.log(grouped) |
| | | const result = Object.keys(grouped).map((key, idx) => { |
| | | const group = grouped[key]; |
| | | const positionGround = group.groundPoiId.getValue(Cesium.JulianDate.now()) |
| | |
| | | const aerialPos = Cesium.Cartographic.fromCartesian(positionAerialPo); |
| | | return { |
| | | id: this.genId(), |
| | | label: `地面点${idx}`, |
| | | label: `地面点${key}`, |
| | | longitude: Cesium.Math.toDegrees(groundPos.longitude), |
| | | latitude: Cesium.Math.toDegrees(groundPos.latitude), |
| | | height: groundPos.height, |
| | | children: [ |
| | | { |
| | | id: this.genId(), |
| | | label: `空中点${idx}`, |
| | | label: `空中点${key}`, |
| | | longitude: Cesium.Math.toDegrees(aerialPos.longitude), |
| | | latitude: Cesium.Math.toDegrees(aerialPos.latitude), |
| | | height: aerialPos.height, |
| | |
| | | const aerialPos = Cesium.Cartographic.fromCartesian(positionAerialPo); |
| | | return { |
| | | id: this.genId(), |
| | | label: `地面点${idx}`, |
| | | label: `地面点${key}`, |
| | | longitude: Cesium.Math.toDegrees(groundPos.longitude), |
| | | latitude: Cesium.Math.toDegrees(groundPos.latitude), |
| | | height: groundPos.height, |
| | | children: [ |
| | | { |
| | | id: this.genId(), |
| | | label: `空中点${idx}`, |
| | | label: `空中点${key}`, |
| | | longitude: Cesium.Math.toDegrees(aerialPos.longitude), |
| | | latitude: Cesium.Math.toDegrees(aerialPos.latitude), |
| | | height: aerialPos.height |
| | |
| | | }; |
| | | }); |
| | | this.$emit('mergePoint',result,this.mergeNumber,viewerM) |
| | | window.removeEventListener("keydown", this.onKeyDown); |
| | | window.removeEventListener("keyup", this.onKeyUp); |
| | | }, |
| | | genId() { |
| | | return (Date.now().toString(16) + Math.random().toString(16).slice(2, 10)).slice(0, 16); |
| | |
| | | <i |
| | | class="el-icon-success" |
| | | ></i> |
| | | <i |
| | | class="el-icon-delete" |
| | | @click.stop="deleteItem(wp)" |
| | | ></i> |
| | | <div class="waypoint-contnet"> |
| | | <span class="waypoint-index">{{ wp.label +'----' +wp.children[0].label }}</span> |
| | | <span v-for="(action, aIndex) in wp.children[0].actions" |
| | |
| | | console.log(this.treeData) |
| | | console.log(this.waypoints) |
| | | console.log(data) |
| | | console.log(this.lastTableArr) |
| | | const byLabel = this.addOrUpdate(this.lastTableArr, data, 'label', this) |
| | | this.waypoints = this.lastTableArr |
| | | console.log(byLabel) |
| | |
| | | }, |
| | | clickItem(value){ |
| | | this.$refs.initMap.editAction(value); |
| | | }, |
| | | extractNumberFromLabel(label){ |
| | | const match = label.match(/(\d+)/); // 获取标签中的数字 |
| | | return match ? match[0] : null; |
| | | }, |
| | | deleteItem(item){ |
| | | this.treeData = this.treeData.filter(obj=>obj.id != item.id) |
| | | this.lastTableArr = this.lastTableArr.filter(obj=>obj.id != item.id) |
| | | const data1LabelNumber = this.extractNumberFromLabel(item.label); |
| | | |
| | | // 创建一个新的EntityCollection,只保留不匹配的实体 |
| | | const filteredEntities = window.viewerM.entities.values.filter(entity => { |
| | | const entityIdNumber = this.extractNumberFromLabel(entity.id); // 提取实体的id中的数字 |
| | | return entityIdNumber !== data1LabelNumber; // 如果数字不一致,保留该实体 |
| | | }); |
| | | // 清空原来的entities集合并重新添加过滤后的实体 |
| | | window.viewerM.entities.removeAll(); // 清空所有实体 |
| | | filteredEntities.forEach(entity => window.viewerM.entities.add(entity)) |
| | | console.log(item) |
| | | console.log(this.treeData) |
| | | console.log(this.lastTableArr) |
| | | console.log(window.viewerM.entities.values) |
| | | // console.log(window.viewerM.entities.values[0].id) |
| | | // console.log(window.viewerM.entities.values[1].id) |
| | | // console.log(window.viewerM.entities.values[2].id) |
| | | // console.log(window.viewerM.entities.values[3].id) |
| | | |
| | | } |
| | | } |
| | | } |