北京经济技术开发区经开区虚拟城市项目-【前端】-Web
lixuliang
2024-05-08 10ecfd0b60442d209d1ab4b749580ffb638d1992
src/components/map/viewer.vue
@@ -1,8 +1,10 @@
<template>
  <div>
    <div id="sdkContainer"></div>
    <div class="listBox" v-show="viewer1Show && !isLand">
      <ul>
      <ul id="viewer_lsyx">
        <li
          v-for="(item, index) in arr"
          :key="index"
@@ -12,6 +14,7 @@
        </li>
      </ul>
    </div>
    <layerTreeTwoScreen v-if="layerTreeTwoScreen" />
    <!-- <div id="bottomInfo" v-html="bottomInfo"></div> -->
    <div
@@ -67,6 +70,10 @@
import "animate.css";
import Bus from "@tools/Bus";
import mapData from "../../../static/mapData";
import mapMsg from "../../assets/js/mapMsg";
import vueEvents from "@/utils/vueEvent.js";
let activeLi, nLayer, LWLayer;
export default {
  name: "viewer",
@@ -96,28 +103,41 @@
  },
  computed: {
    ...mapState(["viewer1Show", "isLand", "layerTreeTwoScreen", "cesiumInit"]),
  },
  watch: {
    viewer1Show(newvalue, oldvalue) {
      if (!newvalue) {
        this.destroyImageLayer();
      } else {
        if (!this.isLand) {
          this.initLSYX();
        }
      }
    },
    isLand(newvalue, oldvalue) {
      if (newvalue) {
        this.destroyImageLayer();
      } else {
        this.initLSYX();
      }
    },
  },
  mounted() {
    let pathName = window.location.pathname.split("/");
    let StaticFileBaseUrl;
    if (pathName.length != 2) {
      StaticFileBaseUrl = `../../../${pathName[1]}/static/CimSDK/`;
    } else {
      StaticFileBaseUrl = `../../../static/CimSDK/`;
    }
    this.$nextTick(function () {
      let that = this;
      //*********北京sdk************
      window.sgworld = new SmartEarth.EarthCtrl(
        "sdkContainer",
        {
          StaticFileBaseUrl: "../../../static/CimSDK/",
          // StaticFileBaseUrl: "../../../SW/static/CimSDK/",
          StaticFileBaseUrl: StaticFileBaseUrl,
        },
        {},
        {},
@@ -157,12 +177,15 @@
              },
              duration: 5, //飞行时间8s
            });
            // console.log("加载完成");
          }, 14000);
          that.setCesiumInit(true);
        }
      );
      window.Viewer = sgworld._Viewer;
      window.sgwfs = new SmartEarth.WFSTool(sgworld._Viewer);
      window.viewer = sgworld._Viewer;
      sgworld._Viewer.scene.moon.show = false;
      window.sgwfs = new SmartEarth.WFSTool(sgworld._Viewer, Cesium);
      Viewer.shadows = false;
      //深度检测
      sgworld.Analysis.depthTestAgainstTerrain(true);
@@ -170,6 +193,10 @@
      // Viewer.scene.screenSpaceCameraController.enableCollisionDetection = false;
      Viewer.scene.globe.translucency.frontFaceAlpha = 0.5;
      Viewer.scene.globe.undergroundColor = undefined;
      mapMsg.init();
      // rpc.clickToCoordinates();
      // mapMsg.setTime();
      //开启编辑并启用属性弹窗
      sgworld.Creator.SimpleGraphic.setEdit(true, {
        editProp: true,
@@ -278,6 +305,11 @@
        this.destroyImageLayer();
      }
    },
    initLSYX() {
      let ul = document.getElementById("viewer_lsyx");
      let lis = ul.getElementsByTagName("li");
      lis[19].click();
    },
    destroyImageLayer() {
      if (activeLi) {
        activeLi.classList.remove("active");
@@ -308,7 +340,10 @@
        nLayer = null;
      }
      nLayer = this.loadBJ54ImageLayer(year);
      if (!LWLayer) {
      if (!LWLayer || Viewer.imageryLayers.indexOf(LWLayer) < 0) {
        if (LWLayer) {
          LWLayer.destroy();
        }
        LWLayer = this.loadBJ54LWLayer();
      }
    },
@@ -458,6 +493,11 @@
          cancel: function () {
            if (cancelFn && typeof cancelFn === "function") {
              cancelFn();
              if (window.pickFeature && window.pickFeature.primitive) {
                window.pickFeature.primitive.image = imgUrl;
                window.pickFeature.primitive.scale = scale;
                window.pickFeature = null;
              }
            }
          },
          end: function () {