修改点功能完善

tykong-cidian
dongjiajun 2024-07-08 18:11:13 +08:00
parent 716dec950b
commit 504b9c9225
2 changed files with 30 additions and 19 deletions

View File

@ -138,8 +138,8 @@
</div> </div>
<canvas v-show="checkRealityWait" id="scaleBar"></canvas> <canvas v-show="checkRealityWait" id="scaleBar"></canvas>
<div class="update-btns" v-show="updatePointVisible"> <div class="update-btns" v-show="updatePointVisible">
<div><el-button type="primary" @click="selectPoint" :disabled="isSelectPointDisabled">选取点</el-button></div> <div><el-button type="primary" @click.stop="selectPoint" :disabled="isSelectPointDisabled">选取点</el-button></div>
<div><el-button type="primary" @click="savePoint"></el-button></div> <div><el-button type="primary" @click.stop="savePoint">保存点</el-button></div>
</div> </div>
</div> </div>
</div> </div>
@ -261,15 +261,13 @@ export default {
updatePointVisible:false, updatePointVisible:false,
currentSelectPoint: null, // currentSelectPoint: null, //
updatedPoint:null, // updatedPoint:null, //
isClickEventOpen:true, isClickEventOpen:true, //
isSelectPointDisabled:false, isSelectPointDisabled:false,
}; };
}, },
mounted() { mounted() {
cu.initCesium("cesiumView"); cu.initCesium("cesiumView");
// if(this.isClickEventOpen){ cu.handleClick();
// cu.handleClick();
// }
cu.addlayer(this.geoWorkSpace, this.geoLayerName); cu.addlayer(this.geoWorkSpace, this.geoLayerName);
let gp = this.geoLayerPos; let gp = this.geoLayerPos;
cu.flyToLayerRect(gp[0], gp[1], gp[2], gp[3]); cu.flyToLayerRect(gp[0], gp[1], gp[2], gp[3]);
@ -439,6 +437,7 @@ export default {
} }
}, },
pickValue() { pickValue() {
cu.destoryHandleClick()
if(this.isClickEventOpen){ if(this.isClickEventOpen){
cu.handleClick(); cu.handleClick();
} }
@ -610,6 +609,7 @@ export default {
}); });
}, },
editSelected(index, simpleData) { editSelected(index, simpleData) {
cu.destoryHandleClick() //
// //
this.updatePointVisible = true; this.updatePointVisible = true;
this.isClickEventOpen = false;// this.isClickEventOpen = false;//
@ -629,6 +629,7 @@ export default {
}, },
// //
selectPoint(){ selectPoint(){
this.isClickEventOpen = false;//
// //
cu.clickToAddPoint(point=>{ cu.clickToAddPoint(point=>{
this.updatedPoint = { this.updatedPoint = {
@ -652,13 +653,15 @@ export default {
cu.addPoint(this.simpleData[i].lng, this.simpleData[i].lat, 10); cu.addPoint(this.simpleData[i].lng, this.simpleData[i].lat, 10);
} }
} }
//
this.$refs.multipleTable.toggleAllSelection(); this.$refs.multipleTable.toggleAllSelection();
// //
this.updatePointVisible = false; this.updatePointVisible = false;
// //
cu.destroyClickToAddPoint() cu.destroyClickToAddPoint()
this.isClickEventOpen = true;
this.isSelectPointDisabled = false; this.isSelectPointDisabled = false;
this.isClickEventOpen = true;
cu.handleClick()
} }
}, },
computed: { computed: {

View File

@ -178,13 +178,13 @@ class CesiumUtils {
//修改点的位置 //修改点的位置
static clickToAddPoint(callback){ static clickToAddPoint(callback){
//清空之前的handler //清空之前的handler
if (this.handler) { if (this.addPointHandler) {
this.handler.destroy(); this.addPointHandler.destroy();
} }
var scene = this.viewer.scene; var scene = this.viewer.scene;
this.handler = new Cesium.ScreenSpaceEventHandler(scene.canvas); this.addPointHandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
const that = this; const that = this;
this.handler.setInputAction(function (movement) { this.addPointHandler.setInputAction(function (movement) {
// 清除历史单击点 // 清除历史单击点
var cartesian = that.viewer.camera.pickEllipsoid( var cartesian = that.viewer.camera.pickEllipsoid(
movement.position, movement.position,
@ -215,17 +215,19 @@ class CesiumUtils {
} }
//销毁监听 //销毁监听
static destroyClickToAddPoint(){ static destroyClickToAddPoint(){
this.handler.destroy(); if(this.addPointHandler){
this.addPointHandler.destroy();
}
} }
//鼠标点击 //鼠标点击
static handleClick() { static handleClick() {
var scene = this.viewer.scene; var scene = this.viewer.scene;
var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas); this.clickShowPopHandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
const that = this; const that = this;
that.clickShowPopHandler.setInputAction(function (movement) {
handler.setInputAction(function (movement) { console.log(123);
// 清除历史单击点 // 清除历史单击点
handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK); that.clickShowPopHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
// movement.position 像素的x、y坐标 // movement.position 像素的x、y坐标
var cartesian = that.viewer.camera.pickEllipsoid( var cartesian = that.viewer.camera.pickEllipsoid(
movement.position, movement.position,
@ -343,6 +345,12 @@ class CesiumUtils {
}); });
}, Cesium.ScreenSpaceEventType.LEFT_CLICK); }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
} }
//销毁点击事件
static destoryHandleClick(){
if(this.clickShowPopHandler){
this.clickShowPopHandler.destroy()
}
}
} }
export default CesiumUtils; export default CesiumUtils;