【类 型】: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: { computed: {
defaultLnglat () { defaultLnglat () {
return this.$store.getters['app/getDefaultLngLat'] return this.$store.getters['app/getDefaultLngLat']
@ -228,18 +250,28 @@ export default {
}) })
/* 地图控件 */ /* 地图控件 */
// //
if (this.enblueTranslate) {
this.map.addControl(new mapboxgl.NavigationControl(), 'top-right') 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')
}
// //
if (this.enableZoom) {
this.map.addControl(new CustomFullscreenControl(this.handleResize), 'top-right') this.map.addControl(new CustomFullscreenControl(this.handleResize), 'top-right')
}
// //
// //
if (this.enableSwitch) {
const styleSwitcherControl = new MapboxStyleSwitcherControl(this.mapStyles, 'iconfont icon-duozhang f-s-20', this.currentStyleIndex) const styleSwitcherControl = new MapboxStyleSwitcherControl(this.mapStyles, 'iconfont icon-duozhang f-s-20', this.currentStyleIndex)
this.map.addControl(styleSwitcherControl, 'top-right') this.map.addControl(styleSwitcherControl, 'top-right')
}
// //
if (this.enableFollow) {
this.map.addControl(new FollowControl({ this.map.addControl(new FollowControl({
defaultIconClass: 'iconfont icon-weidingwei f-s-20', // defaultIconClass: 'iconfont icon-weidingwei f-s-20', //
activeIconClass: 'iconfont icon-dingwei f-s-20 brandFontColor', // activeIconClass: 'iconfont icon-dingwei f-s-20 brandFontColor', //
@ -250,6 +282,7 @@ export default {
} }
} }
}), 'top-right') }), 'top-right')
}
}, },
/** /**
* @description: 清除地图上的航线 * @description: 清除地图上的航线

View File

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

View File

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