<template> <!-- 海绵综合一张图图例 --> <div class="lengendPage"> <!-- 图例框 --> <div class="publicLegend"> <div class="legendTitle"> <div class="legendName">图层控制</div> </div> <div class="legendContent"> <div v-for="item in legendList" :key="item.layername" style="width: 100%"> <div class="titleB" @click="changeAllLegend(item)"> <div class="iconImg"> <el-icon v-if="item.isCheck" size="18"> <Check /> </el-icon> </div> {{ item.title }} </div> <div class="legendItemContent"> <div class="part" v-for="item2 in item.children"> <div class="partItem" v-for="item3 in item2" @click="changeLegend(item3)"> <div class="iconImg"> <el-icon v-if="item3.isCheck" size="15"> <Check /> </el-icon> </div> <img :src="getImageUrl(item3.url, 'cesiumMap/legendIcon')" class="img" /> <p class="title">{{ item3.name }}</p> </div> </div> </div> </div> </div> </div> </div> </template> <script setup> import { getImageUrl } from '@/utils/ruoyi'; import cesiumMapLegend from './cesiumMapLegend.js'; import changeMapStyle from './changeMapStyle.js'; import topography from '@/assets/newImgs/topography.png'; import cesiumPaiShuiArea from './cesiumPaiShuiArea.js'; const { proxy } = getCurrentInstance(); const legendList = ref([]); const ifExpand = ref(true); // 展开收起 const changeZhan = () => { ifExpand.value = !ifExpand.value; }; //图例一级标题点击 const changeAllLegend = item => { console.log('item---', item); item.isCheck = !item.isCheck; }; //图例点击 const changeLegend = item => { item.isCheck = !item.isCheck; console.log('item--', item); if (item.layername == 'whiteMap') { legendList.value[0]['children'][0][1].isCheck = false; legendList.value[0]['children'][1][0].isCheck = false; changeMapStyle.mapSetWhiteStyle(newfiberMap); } if (item.layername == 'blackMap') { legendList.value[0]['children'][0][0].isCheck = false; legendList.value[0]['children'][1][0].isCheck = false; changeMapStyle.mapSetBlueStyle(newfiberMap); } if (item.layername == 'imageMap') { legendList.value[0]['children'][0][0].isCheck = false; legendList.value[0]['children'][0][1].isCheck = false; changeMapStyle.mapSetImageStyle(newfiberMap); } if (item.layername == 'topography') { newfiberMap.getMap().entities.add({ id: 'topography', rectangle: { coordinates: Cesium.Rectangle.fromDegrees(114.111405832621, 34.557500575175, 114.508475798663, 34.904081845253), material: new Cesium.ImageMaterialProperty({ // 纹理 image: topography, // repeat: new Cesium.Cartesian2(4, 4), // color: Cesium.Color.BLUE, transparent: true, }), }, }); //newfiberMap.getMap().entities.removeById('topography'); } if (item.layername == 'cesiumPaishuiArea1') { legendList.value[0]['children'][5][0].isCheck = false; legendList.value[0]['children'][6][0].isCheck = false; cesiumPaiShuiArea.addCesiumPaishuiArea1(newfiberMap); newfiberMap.removeByIds(['cesiumPaishuiArea2', 'cesiumPaishuiArea3']); } if (item.layername == 'cesiumPaishuiArea2') { legendList.value[0]['children'][4][0].isCheck = false; legendList.value[0]['children'][6][0].isCheck = false; cesiumPaiShuiArea.addCesiumPaishuiArea2(newfiberMap); newfiberMap.removeByIds(['cesiumPaishuiArea1', 'cesiumPaishuiArea3']); } if (item.layername == 'cesiumPaishuiArea3') { legendList.value[0]['children'][4][0].isCheck = false; legendList.value[0]['children'][5][0].isCheck = false; cesiumPaiShuiArea.addCesiumPaishuiArea3(newfiberMap); newfiberMap.removeByIds(['cesiumPaishuiArea1', 'cesiumPaishuiArea2']); } }; onMounted(() => { legendList.value = cesiumMapLegend; }); </script> <style lang="scss"> .lengendPage { position: absolute; left: 500px; bottom: 60px; z-index: 205; // background: red; width: 347px; height: 554px; overflow-x: hidden; overflow-y: auto; .publicLegend { width: 347px; height: 654px; background: #003b6d; // border: 1px solid #6acefe; opacity: 0.8; .legendTitle { width: 345px; height: 46px; position: absolute; top: 1px; background: url('@/assets/cesiumMap/legendIcon/legendTitle_img.png'); .legendName { margin: 10px 255px 15px 9px; font-family: YouSheBiaoTiHei; font-weight: 400; font-size: 22px; color: #e4f5ff; } } .legendContent { position: absolute; width: 345px; top: 47px; .titleB { margin-top: 20px; margin-bottom: 20px; display: flex; height: 17px; font-family: Source Han Sans CN; font-weight: 500; font-size: 16px; color: #3afff8; .iconImg { margin-top: 3px; margin-left: 21px; margin-right: 10px; width: 16px; height: 16px; border: 2px solid #41f4ee; .el-icon { font-weight: bold; &.active { color: #41f4ee; } } } } .legendItemContent { width: 100%; .part { width: 100%; display: flex; height: 30px; align-items: center; cursor: pointer; .partItem { margin-left: 47px; display: flex; width: 180px; &:hover { background: #08596a; } .img { width: 16px; height: 16px; margin-left: 10px; margin-right: 5px; } .title { font-family: Source Han Sans CN; font-weight: 500; font-size: 14px; color: #b8ecff; } .iconImg { width: 16px; height: 16px; border: 1px solid #a6daf0; .el-icon { font-weight: bold; &.active { color: #00ee6f; } } } } } } } } } </style>