<script lang="ts" setup>
import {init, loadedStatus, loadMap} from "@/utils/mapConfig";
import {onMounted, watch} from "vue";
import {useMapStore} from "@/stores/map";

const store = useMapStore()
const stationPointBlueImage = new URL('@/assets/images/map/station-point-blue.png', import.meta.url).href
const stationPointGreenImage = new URL('@/assets/images/map/station-point-green.png', import.meta.url).href
const stationPointYellowImage = new URL('@/assets/images/map/station-point-yellow.png', import.meta.url).href
const stationPointGrayImage = new URL('@/assets/images/map/station-point-gray.png', import.meta.url).href


onMounted(() => {
  init({
    images: [
      {name: 'stationPointBlue', src: stationPointBlueImage},
      {name: 'stationPointGreen', src: stationPointGreenImage},
      {name: 'stationPointYellow', src: stationPointYellowImage},
      {name: 'stationPointGray', src: stationPointGrayImage},
    ]
  })
})

watch(() => store.mapOption, async (option) => {
  while (!loadedStatus) {
    await new Promise(resolve => setTimeout(resolve, 500));
  }
  loadMap(option)
})
</script>

<template>
  <div class="gw-map">
    <!-- 2D地图 -->
    <div id="mapDiv"></div>
    <!--    <div v-if="legendList && legendList.length > 0" ref="mapLegend" :style="legendStyle" class="map-legend">-->
    <!--      <ul>-->
    <!--        <li v-for="(item, index) in legendList" :key="index">-->
    <!--          <span :title="item.label">{{ item.label }}</span>-->
    <!--          <template v-if="item.imgType === 'svg'">-->
    <!--            <svg-icon :icon-class="item.src" :style="item.imgStyle" class="image"></svg-icon>-->
    <!--          </template>-->
    <!--          <template v-if="item.imgType === 'img'">-->
    <!--            <el-image :src="item.src" :style="item.imgStyle" class="image"></el-image>-->
    <!--          </template>-->
    <!--        </li>-->
    <!--      </ul>-->
    <!--    </div>-->
  </div>
</template>
<style lang="scss" scoped>
.gw-map {
  width: 100%;
  height: 100%;
  position: relative;
  pointer-events: auto;
  background-image: url('@/assets/images/xk.jpg');
  //background-repeat: no-repeat;
  background-size: cover;
}

#mapDiv {
  width: 100%;
  height: 100%;
  z-index: 1;
  opacity: 1;
  overflow: hidden;
  filter: saturate(1) contrast(1) hue-rotate(0deg) brightness(1);
  transform: rotateZ(0deg) rotateX(0deg) rotateY(0deg) skewX(0deg) skewY(0deg);
}

.map-legend {
  position: absolute;
  bottom: 0;
  right: 0;
  z-index: 100;
  background-color: #f2f2f2;
  border-radius: 8px;
  padding: 5px 10px;

  ul {
    margin: 0;
    padding: 0;

    li {
      margin: 5px 0;
      list-style: none;
      display: flex;
      justify-content: flex-end;
      align-items: center;

      span {
        text-align: right;
        width: 7vw;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .image {
        margin-left: 5px;
        width: 1rem;
        height: 1rem;
      }

    }
  }

}

:deep(.l7-control-logo) {
  display: none;
}

:deep(.esri-view-surface) {
  &:after {
    display: none;
  }
}

</style>
<style lang="scss">
.entry-card-component {
  .entry-base-info {

    .base-info {
      display: flex;
      margin-bottom: 14px;

      .entry-avatar {
        width: 90px;
        margin-right: 8px;
        height: 108px;

        img {
          width: 100%;
          height: 100%;
          object-fit: cover;
        }

      }

      .entry-text-info {
        flex: 1;

        .entry-name {
          font-size: 16px;
          line-height: 22px;
          font-weight: 600;
          margin-bottom: 10px;
          margin-right: 24px;
        }

        .entry-desc {
          line-height: 20px;
          font-size: 12px;
          word-break: break-word;
          display: -webkit-box;
          height: 80px;
          overflow: hidden;
          text-overflow: ellipsis;
          -webkit-line-clamp: 4;
        }
      }
    }


  }

  .entry-nodes {
    .nodes-list {
      border-top: 1px solid #ebebeb;
      padding-top: 7px;

      .node-item {
        cursor: pointer;

        .title {
          word-break: break-word;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          overflow: hidden;
          text-overflow: ellipsis;
          -webkit-line-clamp: 2;
        }

        .sub-title {
          display: flex;
          margin-bottom: 8px;
          color: #999;
          line-height: 14px;

          .time {
            margin-right: 4px;
          }

          .address {
            overflow: hidden;
          }
        }

        .desc {
          font-size: 12px;
          color: #666;
          line-height: 20px;
          max-height: 40px;
        }
      }

    }
  }
}
</style>
