【类 型】:feat 参数控制 地图 子组件 显隐

【原  因】:比如跟随飞机组件 在概况地图中时不用显示的
【过  程】:通过参数设置
【影  响】:
This commit is contained in:
tk 2024-08-08 14:40:30 +08:00
parent 76ea908a1c
commit ff61e2c45f
3 changed files with 96 additions and 20 deletions

View File

@ -133,6 +133,28 @@ export default {
]
}
},
props: {
enableFollow: { //
type: Boolean,
default: false
},
enableSwitch: { //
type: Boolean,
default: true
},
enableZoom: { //
type: Boolean,
default: true
},
enblueTranslate: { //
type: Boolean,
default: true
},
enblueScale: { //
type: Boolean,
default: false
}
},
computed: {
defaultLnglat () {
return this.$store.getters['app/getDefaultLngLat']
@ -228,28 +250,39 @@ export default {
})
/* 地图控件 */
//
this.map.addControl(new mapboxgl.NavigationControl(), 'top-right')
if (this.enblueTranslate) {
this.map.addControl(new mapboxgl.NavigationControl(), 'top-right')
}
//
// this.map.addControl(new mapboxgl.ScaleControl(), 'top-right')
if (this.enblueScale) {
this.map.addControl(new mapboxgl.ScaleControl(), 'bottom-right')
}
//
this.map.addControl(new CustomFullscreenControl(this.handleResize), 'top-right')
if (this.enableZoom) {
this.map.addControl(new CustomFullscreenControl(this.handleResize), 'top-right')
}
//
//
const styleSwitcherControl = new MapboxStyleSwitcherControl(this.mapStyles, 'iconfont icon-duozhang f-s-20', this.currentStyleIndex)
this.map.addControl(styleSwitcherControl, 'top-right')
if (this.enableSwitch) {
const styleSwitcherControl = new MapboxStyleSwitcherControl(this.mapStyles, 'iconfont icon-duozhang f-s-20', this.currentStyleIndex)
this.map.addControl(styleSwitcherControl, 'top-right')
}
//
this.map.addControl(new FollowControl({
defaultIconClass: 'iconfont icon-weidingwei f-s-20', //
activeIconClass: 'iconfont icon-dingwei f-s-20 brandFontColor', //
onClick: (isActive) => {
this.isflow = isActive // isflow
if (this.isflow) {
this.goto(this.planes[0].getLngLat()) //
if (this.enableFollow) {
this.map.addControl(new FollowControl({
defaultIconClass: 'iconfont icon-weidingwei f-s-20', //
activeIconClass: 'iconfont icon-dingwei f-s-20 brandFontColor', //
onClick: (isActive) => {
this.isflow = isActive // isflow
if (this.isflow) {
this.goto(this.planes[0].getLngLat()) //
}
}
}
}), 'top-right')
}), 'top-right')
}
},
/**
* @description: 清除地图上的航线

View File

@ -13,8 +13,8 @@
</div>
<!-- 飞机模式 -->
<div class="flex">
<div v-if="planeMode" class="plane-mode p-l-5 p-r-5 mc mac">
<font class="plane-mode-text">{{ planeMode }}</font>
<div v-if="getPlaneMode" class="plane-mode p-l-5 p-r-5 mc mac">
<font class="plane-mode-text">{{ getPlaneMode }}</font>
</div>
<div class="tag flex mac mc iconfont icon-moshixuanze">
</div>
@ -37,7 +37,7 @@
</div>
<!-- 电池电流 -->
<div class="flex">
<div v-if="currentBattery " class="plane-mode p-l-5 p-r-5 mc mac">
<div v-if="currentBattery" class="plane-mode p-l-5 p-r-5 mc mac">
<font class="plane-mode-text">{{ currentBattery }}A</font>
</div>
<div class="tag flex mac mc iconfont icon-dianliu">
@ -45,16 +45,25 @@
</div>
<!-- 飞机高度 -->
<div class="flex">
<div v-if="positionAlt" class="plane-mode p-l-5 p-r-5 mc mac">
<font class="plane-mode-text">{{ positionAlt }}</font>
</div>
<div class="tag flex mac mc iconfont icon-gaodu">
</div>
</div>
<!-- 飞机对地速度 -->
<div class="flex">
<div v-if="groundSpeed" class="plane-mode p-l-5 p-r-5 mc mac">
<font class="plane-mode-text">{{ groundSpeed }}/</font>
</div>
<div class="tag flex mac mc iconfont icon-sudu">
</div>
</div>
<!-- 钩子状态 1px solid #ddd-->
<!-- 飞机载重 钩子状态 -->
<div class="flex">
<div v-if="loadweight" class="plane-mode p-l-5 p-r-5 mc mac">
<font class="plane-mode-text">{{hookstatus}} {{ loadweight }}</font>
</div>
<div class="tag flex mac mc iconfont icon-mianxingdiaogou">
</div>
</div>
@ -100,7 +109,7 @@ export default {
return true
},
//
planeMode () {
getPlaneMode () {
if (this.plane && this.plane.planeState) {
return this.plane.planeState.getPlaneMode
}
@ -137,6 +146,34 @@ export default {
}
}
return null
},
//
positionAlt () {
if (this.plane && this.plane.planeState) {
return this.plane.planeState.positionAlt
}
return null
},
//
groundSpeed () {
if (this.plane && this.plane.planeState) {
return this.plane.planeState.groundSpeed
}
return null
},
//
hookstatus () {
if (this.plane && this.plane.planeState) {
return this.plane.planeState.hookstatus
}
return null
},
//
loadweight () {
if (this.plane && this.plane.planeState) {
return this.plane.planeState.loadweight
}
return null
}
},
watch: {

View File

@ -1,6 +1,6 @@
<template>
<div class="h-100">
<map-box ref="mapbox">
<map-box ref="mapbox" :enableFollow="true" :enblueScale="!widthLt480">
<template #content>
<BatteryStatus :plane="plane" />
<PlaneStatus :plane="plane" />
@ -54,6 +54,12 @@ export default {
*/
isCollapse () {
return this.$store.state.app.isCollapse
},
/**
* @description: 屏幕宽度是否小于480
*/
widthLt480 () {
return window.innerWidth < 480
}
},
methods: {