|
@@ -1,5 +1,6 @@
|
|
|
<template>
|
|
|
<div class="ml-legend" v-if="current">
|
|
|
+ {{data_legend[current].isOnAll}}--{{current}}
|
|
|
<template v-if="data_legend[current].items">
|
|
|
<div class="legend">
|
|
|
<main>
|
|
@@ -35,7 +36,13 @@
|
|
|
|
|
|
<script>
|
|
|
import {layerControlNew} from "@/utils/map/AddLayer";
|
|
|
-
|
|
|
+const zhui =[
|
|
|
+ { name: '猪', img: require('@/assets/imgs/deck/page_znfx/zhu32.png'), isOn: true },
|
|
|
+ { name: '牛', img: require('@/assets/imgs/deck/page_znfx/niu32.png'), isOn: true },
|
|
|
+ { name: '羊', img: require('@/assets/imgs/deck/page_znfx/yang32.png'), isOn: true },
|
|
|
+ { name: '鸡', img: require('@/assets/imgs/deck/page_znfx/ji32.png'), isOn: true },
|
|
|
+ { name: '鸽', img: require('@/assets/imgs/deck/page_znfx/ge32.png'), isOn: true },
|
|
|
+]
|
|
|
export default {
|
|
|
name: 'MapLegend',
|
|
|
props: ['checkedLayers'],
|
|
@@ -219,12 +226,16 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- toggleLegend(item='all') {
|
|
|
+ toggleLegend(item='all',isTure) {
|
|
|
// this.$emit('orgname',this.data_yzc)
|
|
|
if(item==='all') { //全部类别
|
|
|
- this.data_legend[this.current].items.forEach(i => i.isOn = !this.data_legend[this.current].isOnAll)
|
|
|
- this.data_legend[this.current].isOnAll = !this.data_legend[this.current].isOnAll
|
|
|
- this.$bus.$emit('allAni',this.data_legend[this.current].isOnAll)
|
|
|
+ let isS = !this.data_legend[this.current]?.isOnAll
|
|
|
+ if (isTure!==undefined){
|
|
|
+ isS = isTure
|
|
|
+ }
|
|
|
+ this.data_legend[this.current]?.items.forEach(i => i.isOn = isS)
|
|
|
+ this.data_legend[this.current] && (this.data_legend[this.current].isOnAll = isS)
|
|
|
+ this.$bus.$emit('allAni',!isS)
|
|
|
} else { //细分类别
|
|
|
console.log('888888888',item)
|
|
|
this.data_legend[this.current].items.find(i => i.name===item.name).isOn = !item.isOn
|
|
@@ -236,7 +247,7 @@ export default {
|
|
|
}
|
|
|
|
|
|
let arr = []
|
|
|
- for(let i of this.data_legend[this.current].items){
|
|
|
+ for(let i of this.data_legend[this.current]?.items){
|
|
|
if(i.isOn){
|
|
|
arr.push(i.name)
|
|
|
}
|
|
@@ -259,6 +270,16 @@ export default {
|
|
|
}
|
|
|
|
|
|
},
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ if (!this.data_legend[this.current]?.isOnAll){
|
|
|
+ console.log('没有all',this.current)
|
|
|
+
|
|
|
+ this.toggleLegend('all',true)
|
|
|
+ }
|
|
|
+
|
|
|
+ // // this.toggleLegend('all')
|
|
|
+ console.log('lgend重新创建',this.current)
|
|
|
}
|
|
|
}
|
|
|
</script>
|