修改新增点事件逻辑
parent
8db90be785
commit
43e6b9ac2a
|
@ -629,17 +629,15 @@ export default {
|
|||
// });
|
||||
},
|
||||
//选择点
|
||||
async selectPoint(){
|
||||
selectPoint(){
|
||||
//启动新增点,点击地图,新增一个点
|
||||
let res = await cu.clickToAddPoint()
|
||||
cu.addPoint(res.lng, res.lat, 10);
|
||||
this.updatedPoint = {
|
||||
cu.clickToAddPoint(point=>{
|
||||
this.updatedPoint = {
|
||||
...this.currentSelectPoint,
|
||||
lng: res.lng,
|
||||
lat: res.lat
|
||||
lng: point[0],
|
||||
lat: point[1],
|
||||
}
|
||||
console.log(this.updatedPoint,'查看点');
|
||||
console.log(this.simpleData[2],'查看simpleData');
|
||||
})
|
||||
},
|
||||
// 保存点
|
||||
savePoint(){
|
||||
|
@ -657,6 +655,8 @@ export default {
|
|||
this.$refs.multipleTable.toggleAllSelection();
|
||||
//关闭地图按钮
|
||||
this.updatePointVisible = false;
|
||||
//销毁监听
|
||||
cu.destroyClickToAddPoint()
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
|
|
@ -176,12 +176,16 @@ class CesiumUtils {
|
|||
this.viewer.entities.removeAll();
|
||||
}
|
||||
//修改点的位置
|
||||
static clickToAddPoint(){
|
||||
return new Promise((resolve, reject) => {
|
||||
static clickToAddPoint(callback){
|
||||
//清空之前的handler
|
||||
if (this.handler) {
|
||||
this.handler.destroy();
|
||||
}
|
||||
// return new Promise((resolve, reject) => {
|
||||
var scene = this.viewer.scene;
|
||||
var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
|
||||
this.handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
|
||||
const that = this;
|
||||
handler.setInputAction(function (movement) {
|
||||
this.handler.setInputAction(function (movement) {
|
||||
// 清除历史单击点
|
||||
// handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
||||
// movement.position 像素的x、y坐标
|
||||
|
@ -196,13 +200,29 @@ class CesiumUtils {
|
|||
var latitudeString = Cesium.Math.toDegrees(cartographic.latitude).toFixed(6);
|
||||
let lng = Number(longitudeString);
|
||||
let lat = Number(latitudeString);
|
||||
resolve({ lng, lat });
|
||||
}else{
|
||||
reject('未获取到坐标');
|
||||
const positions = [lng, lat];
|
||||
that.viewer.entities.removeById("theNewPoint");
|
||||
that.viewer.entities.add({
|
||||
id: "theNewPoint",
|
||||
position: cartesian,
|
||||
point: {
|
||||
color: Cesium.Color.fromCssColorString('#9cf7e3'),
|
||||
pixelSize: 10
|
||||
// heightReference: Cesium.HeightReference.CLAMP_TO_GROUND
|
||||
}
|
||||
});
|
||||
//通过callback函数将数据传递到外部使用
|
||||
callback(positions);
|
||||
}
|
||||
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
||||
});
|
||||
// });
|
||||
}
|
||||
//销毁监听
|
||||
static destroyClickToAddPoint(){
|
||||
this.handler.destroy();
|
||||
}
|
||||
|
||||
|
||||
//鼠标点击
|
||||
static handleClick() {
|
||||
var scene = this.viewer.scene;
|
||||
|
|
Loading…
Reference in New Issue