<!--
 * @Descripttion: 
 * @version: 
 * @Author: ysh
 * @Date: 2023-06-02 14:13:06
 * @LastEditors: wrh
 * @LastEditTime: 2026-03-23 17:22:16
-->
<template>
  <div class="map-box">
    <div class="open-box" v-if="isClose" @click="closeSwitch">
      <i class="el-icon-d-arrow-right"></i>
    </div>
    <div class="close-box" @click="closeSwitch">
      <i class="el-icon-d-arrow-left"></i>
    </div>
    <el-tooltip class="box-item" effect="dark" content="高德" placement="top">
      <div class="box-item" :class="{ close: isClose }" @click="translateMapBox('高德')">
      </div>
    </el-tooltip>
    <!-- <el-tooltip class="box-item" effect="dark" content="谷歌" placement="top">
      <div class="box-item" :class="{ close: isClose }" @click="translateMapBox('谷歌')">
      </div>
    </el-tooltip>
    <el-tooltip class="box-item" effect="dark" content="天地图" placement="top">
      <div class="box-item" :class="{ close: isClose }" @click="translateMapBox('天地图')">
      </div>
    </el-tooltip> -->
    <el-tooltip class="box-item" effect="dark" content="中科星图" placement="top">
      <div class="box-item" :class="{ close: isClose }" @click="translateMapBox('中科星图')">
      </div>
    </el-tooltip>
    <!-- <el-tooltip class="box-item" effect="dark" content="ArcGIS" placement="top">
      <div class="box-item" :class="{ close: isClose }" @click="translateMapBox('ArcGIS')">
      </div>
    </el-tooltip>
    <el-tooltip class="box-item" effect="dark" content="天地图地形" placement="top">
      <div class="box-item" :class="{ close: isClose }" @click="translateMapBox('天地图地形')">
      </div>
    </el-tooltip>
    <el-tooltip class="box-item" effect="dark" content="矢量图" placement="top">
      <div class="box-item" :class="{ close: isClose }" @click="translateMapBox('矢量图')">
      </div>
    </el-tooltip> -->
  </div>
</template>

<script>
import TileLayer from 'ol/layer/Tile';

export default {
  data() {
    return {
      isClose: true,
    };
  },
  mounted() {
  },
  methods: {
    translateMapBox(type) {
      let layers = this.$store.getters.map.getAllLayers();
      for (let layer of layers) {
        if (layer instanceof TileLayer) {
          layer.setVisible(false);
          let name = layer.getProperties().name;
          if (name == "标注") {
            layer.setVisible(true);
          }
          if (name == type) {
            if (type == '高德') {
              layer.setVisible(true);
            // } else if (type == '天地图') {
            //   layer.setVisible(true);
            } else if (type == '中科星图') {
              layer.setVisible(true);
            // } else if (type == '谷歌') {
            //   layer.setVisible(true);
            // } else if (type == 'ArcGIS') {
            //   layer.setVisible(true);
            // } else if (type == '天地图地形') {
            //   layer.setVisible(true);
            // } else if (type == '矢量图') {
            //   layer.setVisible(true);
            }
          }
        }
      }
    },
    closeSwitch() {
      this.isClose = !this.isClose;
    }
  },
}

</script>

<style lang="scss" scoped>
.map-box {
  display: flex;
  position: relative;

  .box-item {
    width: 100px;
    height: 100px;
    margin: 0px 3px;
    border: 1px solid #000;
    cursor: pointer;
  }
}

.open-box {
  color: #fff;
  position: absolute;
  font-size: 26px;
  right: -132px;
  top: -100px;
  height: 99px;
  line-height: 99px;
  border-radius: 0 3px 3px 0;
  cursor: pointer;
  background-color: rgba($color: #000000, $alpha: 0.5);
  z-index: 13px;
}

.close-box {
  color: #fff;
  position: absolute;
  font-size: 26px;
  right: -26px;
  top: 1px;
  height: 99px;
  line-height: 99px;
  border-radius: 0 3px 3px 0;
  cursor: pointer;
  background-color: rgba($color: #000000, $alpha: 0.5);
}


.box-item:hover {
  border: 2px solid #fff;
}

.close {
  position: absolute;
  left: 0;
  bottom: 0;
}

// .box-item:nth-child(2) {
//   background-image: url('../../../assets/images/gis/高德.PNG');
//   background-size: 100% 100%;
//   z-index: 11;
// }

// .box-item:nth-child(3) {
//   background-image: url('../../../assets/images/gis/谷歌影像.png');
//   background-size: 100% 100%;
//   z-index: 10;
// }

.box-item:nth-child(4) {
  background-image: url('../../../assets/images/gis/天地图.png');
  background-size: 100% 100%;
  z-index: 9;
}

.box-item:nth-child(3) {
  background-image: url('../../../assets/images/gis/中科星图影像.png');
  background-size: 100% 100%;
  z-index: 8;
}

// .box-item:nth-child(6) {
//   background-image: url('../../../assets/images/gis/ArcGIS.PNG');
//   background-size: 100% 100%;
//   z-index: 7;
// }

.box-item:nth-child(7) {
  background-image: url('../../../assets/images/gis/天地图地形图.png');
  background-size: 100% 100%;
  z-index: 7;
}

.box-item:nth-child(8) {
  background-image: url('../../../assets/images/gis/矢量图.png');
  background-size: 100% 100%;
  z-index: 7;
}
</style>