管道基础大数据平台系统开发-【前端】-新系統界面
Surpriseplus
2023-02-28 1b1ed68312363574ba3170aa4cb777fbd1ec25da
src/components/mapol.vue
@@ -1,17 +1,42 @@
<template>
  <div id="mapol">
    <div
      @click="changeMenulayer"
      class="center CenDiv"
      :class="{ center1: centerFlag }"
    >
    <div style="display: flex">
      <div
        id="cenBg"
        v-bind:class="{ active: isActive, menuLayer: isMenuLayer }"
      ></div>
        @click="changeMenulayer"
        class="center CenDiv"
        :class="{ center1: centerFlag }"
      >
        <div
          id="cenBg"
          v-bind:class="{ active: isActive, menuLayer: isMenuLayer }"
        ></div>
      </div>
      <div
        @click="changeMapType"
        class="changeMapType"
      >
        <div
          id="cenBg"
          :class="show2DMap ? 'mapTypeTwo' : 'mapTypeThree'"
        ></div>
      </div>
    </div>
    <div v-show="$store.state.isNaviget"  class="sindagis-map-compass">
    <!--    <div-->
    <!--      @click="changeMenulayer"-->
    <!--      class="center CenDiv"-->
    <!--      :class="{ center1: centerFlag }"-->
    <!--    >-->
    <!--      <div-->
    <!--        id="cenBg"-->
    <!--        v-bind:class="{ active: isActive, menuLayer: isMenuLayer }"-->
    <!--      ></div>-->
    <!--    </div>-->
    <div
      v-show="$store.state.isNaviget"
      class="sindagis-map-compass"
    >
      <span
        class="left"
        @click="leftClick"
@@ -57,13 +82,18 @@
      isActive: true,
      isMenuLayer: false,
      rotate: 0,
      currentDir: ''
      currentDir: '',
      show2DMap: false,
    }
  },
  mounted() {
    this.init2DMap()
    this.init2DMap();
    this.$bus.$on('changemapType', (e) => {
      this.show2DMap = e;
    });
  },
  methods: {
    init2DMap() {
      var vectorLayer = new TileLayer({
        source: new XYZ({
@@ -79,13 +109,13 @@
        target: "mapol",
        layers: [imageLayer, vectorLayer],
        view: new View({
          center:  [105.02, 34.9] ,
          center: [105.02, 34.9],
          zoom: 4,
          projection: "EPSG:4326",
        }),
        controls: defaultControls().extend([
          new FullScreen(),
        ]),
        interactions: defaultInteractions().extend([new DragRotateAndZoom()]),
      })
@@ -99,6 +129,21 @@
        // $(".ol-scale-line").css("left", ($(window).width() - $(".ol-scale-line").width() - 25) + "px");
      });
    },
    //二维/三维地图切换
    changeMapType() {
      //
      this.show2DMap = !this.show2DMap;
      //二维
      if (this.show2DMap) {
        this.$bus.$emit("changemap", 2);
      }
      //三维
      else {
        this.$bus.$emit("changemap", 3);
      }
      this.$bus.$emit("changemapType", this.show2DMap);
    },
    changeMenulayer() {
@@ -281,4 +326,35 @@
  background: url("../assets/img/compass.png") -89px -5px / 266px no-repeat;
}
.changeMapType {
  position: absolute;
  bottom: 1%;
  left: calc(1% + 75px);
  height: 40px;
  width: 60px;
  z-index: 101;
  display: flex;
  justify-content: center;
  align-items: center;
  // box-shadow: 3px 3px 6px #666;
  border-radius: 5px;
  // background: #fff;
  cursor: pointer;
}
.mapTypeTwo {
  width: 100%;
  height: 100%;
  margin-left: 10px;
  background-image: url("../assets/img/synthesis/3D.png");
  background-repeat: no-repeat;
  background-size: contain;
}
.mapTypeThree {
  width: 100%;
  height: 100%;
  margin-left: 10px;
  background-image: url("../assets/img/synthesis/2D 拷贝 2.png");
  background-repeat: no-repeat;
  background-size: contain;
}
</style>