food/src/views/layout/components/main/nofly/set.vue
oldHome 57ee5a54b4 1.改变设置禁飞区的目录结构 删掉列表页 add页改为set页 2.更改路由无 设置进飞机无子项
3.设置禁飞区样式 颜色 红色 4.添加设置按钮  保存按钮及其回调  删除按钮
2025-06-03 03:50:56 +08:00

81 lines
1.7 KiB
Vue

<template>
<div class="h-100">
<map-box ref="mapbox" :enableNofly="true"/>
</div>
</template>
<script>
import MapBox from '@/components/MapBox'
export default {
name: 'Nofly',
data () {
return {
}
},
components: {
MapBox
},
computed: {
airList () {
return this.$store.state.airList
},
/**
* @description: 侧边栏显隐
*/
isCollapse () {
return this.$store.state.app.isCollapse
}
},
methods: {
/**
* @description: 创建飞机图标
*/
makePlanes (planes) {
this.$refs.mapbox.removePlanes()// 先清除画布上现有的飞机
planes.forEach((plane, index) => { // 创建所有飞机
let planeDefaultLonLat
if (localStorage.getItem(plane.name) !== null) { // 从本地缓存 拿飞机得初始位置
planeDefaultLonLat = JSON.parse(localStorage.getItem(plane.name))
plane.lon = planeDefaultLonLat.lon
plane.lat = planeDefaultLonLat.lat
} else {
plane.lon = 0
plane.lat = 0
}
this.$refs.mapbox.makePlane(plane, index)
})
}
},
mounted () {
if (this.airList.length > 0) {
this.makePlanes(this.airList)// 创建飞机图标
}
},
watch: {
/**
* @description: 飞机列表更新时候 更新地图
*/
airList: {
handler (val) {
this.makePlanes(val)
}
},
/**
* @description: 侧边栏缩进有变化时 地图重新自适应
*/
isCollapse: {
handler (val) {
if (val) {
this.$refs.mapbox.handleResize()
}
}
}
},
destroyed () {
}
}
</script>
<style></style>