【类 型】:feat 关闭点飞窗口时 也同时删除 点飞的图标

【原  因】:
【过  程】:
【影  响】:

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
This commit is contained in:
tk 2024-10-11 14:38:46 +08:00
parent bfe0a6ae3c
commit caa837daf8
2 changed files with 25 additions and 14 deletions

View File

@ -21,6 +21,7 @@ export default {
takeoffLonLats: [], // 线 takeoffLonLats: [], // 线
isflow: false, // isflow: false, //
currentStyleIndex: 0, // currentStyleIndex: 0, //
guidedMarker: null, //
// //
mapStyles: [ mapStyles: [
// mapbox // mapbox
@ -234,7 +235,7 @@ export default {
lat: this.map.unproject(currentPoint).lat lat: this.map.unproject(currentPoint).lat
} }
this.$emit('longPress', lonLat) // this.$emit('longPress', lonLat) //
this.makeGuidedMarker(lonLat, this.map) // this.makeGuidedMarker(lonLat) //
} }
}) })
// //
@ -256,7 +257,7 @@ export default {
lat: this.map.unproject(currentPoint).lat lat: this.map.unproject(currentPoint).lat
} }
this.$emit('longPress', lonLat) // this.$emit('longPress', lonLat) //
this.makeGuidedMarker(lonLat, this.map) // this.makeGuidedMarker(lonLat) //
} }
}) })
} }
@ -559,20 +560,26 @@ export default {
/** /**
* @abstract 创建指点飞行标记 * @abstract 创建指点飞行标记
* @param {Array} lonLat - 经纬度数组格式为 [longitude, latitude] * @param {Array} lonLat - 经纬度数组格式为 [longitude, latitude]
* @param {Object} map - mapboxgl 的地图实例
*/ */
makeGuidedMarker (lonLat, map) { makeGuidedMarker (lonLat) {
// //
if (this.guidedMarker) { this.delGuidedMarker()
this.guidedMarker.remove()
this.guidedMarker = null //
}
// //
this.guidedMarker = new mapboxgl.Marker({ this.guidedMarker = new mapboxgl.Marker({
draggable: false// draggable: false//
}) })
.setLngLat(lonLat) .setLngLat(lonLat)
.addTo(map) .addTo(this.map)
},
/**
* @abstract 删除指点飞行标记
*/
delGuidedMarker () {
if (this.guidedMarker) {
this.guidedMarker.remove()
this.guidedMarker = null //
}
}, },
/** /**
* @description: 创建飞机轨迹 ps:原理删除之前的轨迹 重新绘制 * @description: 创建飞机轨迹 ps:原理删除之前的轨迹 重新绘制

View File

@ -14,11 +14,12 @@
@open="openCallback"> @open="openCallback">
<!-- 点飞设置弹出框 --> <!-- 点飞设置弹出框 -->
<template v-if="dialogItem == 'guidedBox'"> <template v-if="dialogItem == 'guidedBox'">
<template> <el-form label-position="left">
<font>高度设置</font> <el-form-item label="高度设置" label-width="80px">
<el-input-number v-model="guidedAlt" label="高度设置"></el-input-number> <el-input-number v-model="guidedAlt" label="高度设置"></el-input-number>
<font class="m-l-5"></font> <font class="m-l-5"></font>
</template> </el-form-item>
</el-form>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button size="medium" @click="dialogVisible = false">关闭</el-button> <el-button size="medium" @click="dialogVisible = false">关闭</el-button>
<el-button size="medium" type="primary" <el-button size="medium" type="primary"
@ -83,6 +84,9 @@ export default {
methods: { methods: {
/** 弹出框 关闭事件回调 */ /** 弹出框 关闭事件回调 */
closeCallback () { closeCallback () {
if (this.dialogItem === 'guidedBox') { //
this.$refs.mapbox.delGuidedMarker()//
}
this.dialogVisible = false this.dialogVisible = false
this.dialogItem = '' this.dialogItem = ''
}, },