北京经济技术开发区经开区虚拟城市项目-【前端】-移动端Web
ZhAkps
2024-02-02 612cfd7a042396cef37ddf39cf150f7bcfe55809
添加二维地图路由
已添加3个文件
已修改4个文件
15421 ■■■■■ 文件已修改
package-lock.json 14325 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
package.json 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/sideMenu/layerMenu/layerPanel.vue 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/sideMenu/layerMenu/layerPanel2.vue 671 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/sideMenu/layerMenu/main2.vue 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/viewer2.vue 390 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/index.js 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
package-lock.json
ÎļþÌ«´ó
package.json
@@ -18,7 +18,8 @@
    "font-awesome": "^4.3.0",
    "jquery": "^3.3.1",
    "lodash": "^4.17.21",
    "ol": "^7.3.0",
    "ol": "^7.4.0",
    "ol-ext": "^4.0.10",
    "sass-loader": "^10.0.4",
    "three": "^0.103.0",
    "vcolorpicker": "^0.1.8",
src/components/sideMenu/layerMenu/layerPanel.vue
@@ -305,7 +305,7 @@
    // äºŒç»´åº•图选择
    handleEMapClick(result, index) {
      let p = sgworld.Navigate.getCameraInfo();
      let pitch ;
      let pitch;
      if (pitch !== -90) {
        pitch = -90;
        sgworld.Navigate.flyToPointsInterest({
@@ -324,10 +324,10 @@
      // è®¾ç½®ç›¸æœº
      if (result.name == "二维地图") {
        window.Viewer.scene.globe.maximumScreenSpaceError = 4/3;
        window.Viewer.scene.globe.maximumScreenSpaceError = 4 / 3;
        this.changeLayerView(25000, false);
      } else if (result.name == "影像地图") {
        window.Viewer.scene.globe.maximumScreenSpaceError = 4/3;
        window.Viewer.scene.globe.maximumScreenSpaceError = 4 / 3;
        this.changeLayerView(50000, false);
      }
      // åˆ‡æ¢å›¾å±‚
src/components/sideMenu/layerMenu/layerPanel2.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,671 @@
<template>
  <div class="layerPanel">
    <div class="mapMode">
      <div class="title" style="margin-top: 0px">地图模式</div>
      <div class="container">
        <div
          class="layerItem"
          :key="value.id"
          v-for="(value, index) in eMapModeList"
          @click.stop="handleEMapClick(value, index)"
        >
          <img
            :src="value.src"
            :class="{ active: curEMapModelIndex == index }"
          />
          <span :class="{ spanActive: curEMapModelIndex == index }">{{
            value.name
          }}</span>
        </div>
        <div
          class="layerItem"
          :key="value0.id"
          v-for="(value0, index0) in sMapModelList"
          @click.stop="handleSMapClick(value0, index0)"
        >
          <img
            :src="value0.src"
            :class="{ active: curSMapModelIndex == index0 }"
          />
          <span :class="{ spanActive: curSMapModelIndex == index0 }">{{
            value0.name
          }}</span>
        </div>
      </div>
    </div>
    <!-- <div class="areaType" style="margin-top: 10px">
      <div class="title">
        ä¸“题图层
        <span class="more" @click.stop="showLayerTree"
          >更多图层<i class="el-icon-arrow-right"></i
        ></span>
      </div>
      <div class="container">
        <div
          class="layerItem"
          :key="value1.id"
          v-for="(value1, index1) in areaTypeList"
          @click.stop="handleAreaClick(value1, index1)"
        >
          <img
            :src="value1.src"
            :class="{ active: curAreaTypeIndex == index1 }"
          />
          <span :class="{ spanActive: curAreaTypeIndex == index1 }">{{
            value1.name
          }}</span>
        </div>
      </div>
    </div> -->
    <div class="areaType" style="margin-top: 10px">
      <div class="title">
        ä¸“题应用
        <!-- ä¸æ˜¾ç¤ºæ›´å¤šå›¾å±‚ -->
        <span class="more" v-show="false" @click.stop="showLayerTree"
          >更多图层<i class="el-icon-arrow-right"></i
        ></span>
      </div>
      <div class="container">
        <div
          class="layerItem"
          v-for="(ZTValue, ZTIndex) in zhuantiList"
          :key="ZTValue.id"
          @click.stop="handleZTlick(ZTValue, ZTIndex)"
        >
          <img :src="ZTValue.src" :class="{ active: curZTIndex == ZTIndex }" />
          <span :class="{ spanActive: curZTIndex == ZTIndex }">{{
            ZTValue.name
          }}</span>
        </div>
      </div>
      <div class="title2"></div>
      <div class="container">
        <div
          class="layerItem"
          v-for="(funcValue, funcIndex) in FuncList"
          :key="funcValue.id"
          @click.stop="handleFuncClick(funcIndex)"
        >
          <img
            :src="funcValue.src"
            :class="{ active: curFuncIndex == funcIndex }"
          />
          <span :class="{ spanActive: curFuncIndex == funcIndex }">{{
            funcValue.name
          }}</span>
        </div>
      </div>
    </div>
    <!-- <div class="yjsxt">
      <div class="title">城市部件</div>
      <div class="container">
        <div
          class="layerItem"
          :key="value2.id"
          v-for="(value2, index2) in yjList"
          @click.stop="handleYJClick(index2)"
        >
          <img :src="value2.src" :class="{ active: curYjIndex == index2 }" />
          <span :class="{ spanActive: curYjIndex == index2 }">{{
            value2.name
          }}</span>
        </div>
      </div>
    </div> -->
  </div>
</template>
<script>
import {
  loadHXQ,
  loadJKQ,
  loadXZ,
  clearMap,
  loadManhole,
  loadCamera,
  loadEnterprise,
  loadLayer,
  clearLayerByTypeId,
  clearLayerByTypeIdArr,
} from "@/utils/map.js";
import _GLOBAL from "@/assets/GLOBAL";
import store from "@/utils/store.js";
import ZTTitem from "@/utils/ztt.js";
import { layers } from "../../../../static/json/layer.js";
export default {
  name: "LayerPanel",
  data() {
    return {
      eMapModeList: [
        {
          id: "ewdt",
          name: "二维地图",
          active: false,
          type: "er",
          src: require("@/assets/img/layer/ewdt.png"),
        },
        {
          id: "yxdt",
          name: "影像地图",
          active: true,
          type: "er",
          src: require("@/assets/img/layer/yxdt.png"),
        },
      ],
      sMapModelList: [
        // {
        //   id: "3Dcs",
        //   name: "3D城市",
        //   active: false,
        //   type: "san",
        //   src: require("@/assets/img/layer/3Dcs.png"),
        // },
        // {
        //   id: "swmx",
        //   name: "三维模型",
        //   active: false,
        //   type: "san",
        //   src: require("@/assets/img/layer/swmx.png"),
        // },
      ],
      areaTypeList: [
        {
          id: "规划范围",
          name: "规划范围",
          active: false,
          src: require("@/assets/img/layer/ghfw.png"),
        },
        {
          id: "XingZhengQuHuaTu",
          name: "行政区划",
          active: false,
          src: require("@/assets/img/layer/xzqh.png"),
        },
        {
          id: "GuiHuaDanYuanHuaFenTu",
          name: "规划单元",
          active: false,
          src: require("@/assets/img/layer/ghdy.png"),
        },
        {
          id: "ZhuYaoGongNengQuGuiHuaShiYiTu",
          name: "功能区域",
          active: false,
          src: require("@/assets/img/layer/gnq.png"),
        },
      ],
      yjList: [
        {
          id: "yinjing",
          name: "窨井",
          active: false,
          src: require("@/assets/img/layer/yj.png"),
        },
        {
          id: "shext",
          name: "摄像头",
          active: false,
          src: require("@/assets/img/layer/sxt.png"),
        },
      ],
      FuncList: [
        {
          id: "tdgl",
          name: "土地管理",
          active: false,
          src: require("@/assets/img/layer/tudiguanli.png"),
        },
        {
          id: "history",
          name: "历史影像",
          active: false,
          src: require("@/assets/img/layer/lishiyingxiang.png"),
        },
      ],
      zhuantiList: ZTTitem,
      //curMapModelIndex: 1,
      curEMapModelIndex: 0,
      curSMapModelIndex: -1,
      curAreaTypeIndex: -1,
      curYjIndex: -1,
      curFuncIndex: -1,
      curZTIndex: -1,
      state: store.thematicLayer,
      basicMapChecked: store.basicMapChecked,
      state1: store.tdglInfo,
    };
  },
  mounted() {
    this.$nextTick(() => {
      setTimeout(() => {
        this.handleEMapClick(
          {
            id: "yxdt",
            name: "影像地图",
            active: true,
            type: "er",
            src: "/static/img/yxdt.cf4698e.png",
          },
          1
        );
        loadEnterprise();
      }, 2000);
    });
  },
  methods: {
    changeLayerView(max, enableTilt) {
      window.Viewer.scene.screenSpaceCameraController.maximumZoomDistance = max;
      window.Viewer.scene.screenSpaceCameraController.enableTilt = enableTilt;
    },
    handleMapClick(result, index) {
      const val = layers.filter((res) => {
        if (res.name == result.name) {
          return res;
        }
      });
      const children = val[0].children;
      if (this.curMapModelIndex == index) {
        clearLayerByTypeId(result.id);
        this.curMapModelIndex = -1;
      } else {
        this.curMapModelIndex = index;
        if (result.type == "er") {
          clearLayerByTypeIdArr(["ewdt", "yxdt"]);
        } else {
          clearLayerByTypeIdArr(["3Dcs", "swmx"]);
        }
        // clearLayerByTypeIdArr(['ewdt', 'yxdt', '3Dcs', 'swmx']);
        _GLOBAL.layers[result.id] = [];
        children.forEach((item) => {
          let itemLayer = loadLayer(item);
          _GLOBAL.layers[result.id].push(itemLayer);
          console.log(_GLOBAL.layers[result.id]);
        });
      }
    },
    // äºŒç»´åº•图选择
    handleEMapClick(result, index) {
      let p = sgworld.Navigate.getCameraInfo();
      let pitch;
      if (pitch !== -90) {
        pitch = -90;
        sgworld.Navigate.flyToPointsInterest({
          destination: new Cesium.Cartesian3.fromDegrees(
            p.location.lon,
            p.location.lat,
            p.location.height
          ),
          orientation: {
            heading: Cesium.Math.toRadians(0),
            pitch: Cesium.Math.toRadians(pitch),
            roll: Cesium.Math.toRadians(0),
          },
        });
      }
      // è®¾ç½®ç›¸æœº
      if (result.name == "二维地图") {
        window.Viewer.scene.globe.maximumScreenSpaceError = 4 / 3;
        this.changeLayerView(25000, false);
      } else if (result.name == "影像地图") {
        window.Viewer.scene.globe.maximumScreenSpaceError = 4 / 3;
        this.changeLayerView(50000, false);
      }
      // åˆ‡æ¢å›¾å±‚
      const val = layers.filter((res) => {
        if (res.name == result.name) {
          return res;
        }
      });
      const children = val[0].children;
      if (this.curEMapModelIndex == index) {
        // å†æ¬¡ç‚¹å‡»é€‰ä¸­çš„item时取消选择
        // clearLayerByTypeId(result.id);
        // this.curEMapModelIndex = -1;
      } else {
        this.curSMapModelIndex = -1;
        this.curEMapModelIndex = index;
        clearLayerByTypeIdArr(["ewdt", "yxdt"]);
        clearLayerByTypeIdArr(["3Dcs", "swmx"]);
        _GLOBAL.layers[result.id] = [];
        children.forEach((item) => {
          let itemLayer = loadLayer(item);
          _GLOBAL.layers[result.id].push(itemLayer);
          // console.log(_GLOBAL.layers[result.id]);
        });
      }
    },
    // ä¸‰ç»´æ¨¡åž‹é€‰æ‹©
    handleSMapClick(result, index) {
      // è®¾ç½®ç›¸æœº
      if (result.name == "3D城市") {
        window.Viewer.scene.globe.maximumScreenSpaceError = 2;
        this.changeLayerView(45000, true);
      } else if (result.name == "三维模型") {
        window.Viewer.scene.globe.maximumScreenSpaceError = 2;
        this.changeLayerView(80000, true);
      }
      // åˆ‡æ¢å›¾å±‚
      const val = layers.filter((res) => {
        if (res.name == result.name) {
          return res;
        }
      });
      const children = val[0].children;
      if (this.curSMapModelIndex == index) {
        // clearLayerByTypeId(result.id);
        // this.curSMapModelIndex = -1;
      } else {
        this.curEMapModelIndex = -1;
        this.curSMapModelIndex = index;
        clearLayerByTypeIdArr(["ewdt", "yxdt"]);
        clearLayerByTypeIdArr(["3Dcs", "swmx"]);
        _GLOBAL.layers[result.id] = [];
        children.forEach((item) => {
          let itemLayer = loadLayer(item);
          _GLOBAL.layers[result.id].push(itemLayer);
          console.log(_GLOBAL.layers[result.id]);
        });
      }
    },
    // ä¸“题图选择
    handleAreaClick(result, index) {
      const val = layers.filter((res) => {
        if (res.name == result.name) {
          return res;
        }
      });
      const children = val[0].children;
      if (this.curAreaTypeIndex == index) {
        this.curAreaTypeIndex = -1;
        let _data = sgworld.ProjectTree.getObject(children[0].id);
        if (_data) {
          sgworld.ProjectTree.setVisibility(children[0].id, false);
        }
        // clearLayerByTypeIdArr(['GuiHuaFanWeiShiYiTu', 'XingZhengQuHuaTu', 'GuiHuaDanYuanHuaFenTu', 'ZhuYaoGongNengQuGuiHuaShiYiTu']);
        store.setThematicLayerItemId("");
      } else {
        this.curAreaTypeIndex = index;
        //清除
        //clearLayerByTypeIdArr(['GuiHuaFanWeiShiYiTu', 'XingZhengQuHuaTu', 'GuiHuaDanYuanHuaFenTu', 'ZhuYaoGongNengQuGuiHuaShiYiTu']);
        let arr = [
          "GuiHuaFanWeiShiYiTu",
          "XingZhengQuHuaTu",
          "GuiHuaDanYuanHuaFenTu",
          "ZhuYaoGongNengQuGuiHuaShiYiTu",
        ];
        arr.forEach((item) => {
          sgworld.ProjectTree.getObject(item) &&
            sgworld.ProjectTree.setVisibility(item, false);
        });
        let dataObj = sgworld.ProjectTree.getObject(result.id);
        if (dataObj) {
          sgworld.ProjectTree.setVisibility(result.id, true);
        } else {
          _GLOBAL.layers[result.id] = [];
          children.forEach((item) => {
            let itemLayer = loadLayer(item);
            _GLOBAL.layers[result.id].push(itemLayer);
            console.log(_GLOBAL.layers[result.id]);
          });
        }
        store.setThematicLayerItemId(result.id);
      }
    },
    // çª¨äº•加载
    handleYJClick(index) {
      if (this.curYjIndex == index) {
        this.curYjIndex = -1;
        window.clusterLayer && window.clusterLayer.clear();
      } else {
        this.curYjIndex = index;
        switch (index) {
          case 0:
            loadManhole();
            break;
          case 1:
            loadCamera();
            break;
          case 2:
            loadEnterprise();
            break;
        }
      }
    },
    // ç¬¬äºŒè¡Œ ä¸“题图 ç‚¹å‡»
    handleZTlick(result, index) {
      const val = layers.filter((res) => {
        if (res.name == result.name) {
          return res;
        }
      });
      const children = val[0].children;
      if (this.curZTIndex == index) {
        this.curZTIndex = -1;
        //   let _data = sgworld.ProjectTree.getObject(children[0].id);
        //   if (_data) {
        //     sgworld.ProjectTree.setVisibility(children[0].id, false);
        //   }
        store.setThematicLayerItemId("");
      } else {
        this.curZTIndex = index;
        store.setThematicLayerItemId(children);
        //   //清除
        //   // let arr = [
        //   //   "GuiHuaFanWeiShiYiTu",
        //   //   "XingZhengQuHuaTu",
        //   //   "GuiHuaDanYuanHuaFenTu",
        //   //   "ZhuYaoGongNengQuGuiHuaShiYiTu",
        //   // ];
        //   // arr.forEach((item) => {
        //   //   sgworld.ProjectTree.getObject(item) &&
        //   //     sgworld.ProjectTree.setVisibility(item, false);
        //   // });
        //   let dataObj = sgworld.ProjectTree.getObject(result.id);
        //   if (dataObj) {
        //     sgworld.ProjectTree.setVisibility(result.id, true);
        //   } else {
        //     _GLOBAL.layers[result.id] = [];
        //     children.forEach((item) => {
        //       let itemLayer = loadLayer(item);
        //       _GLOBAL.layers[result.id].push(itemLayer);
        //       console.log(_GLOBAL.layers[result.id]);
        //     });
        //   }
        //   // store.setThematicLayerItemId(result.id);
      }
    },
    // ç¬¬ä¸‰è¡Œ ä¸“题功能 ç‚¹å‡»
    handleFuncClick(index) {
      if (this.curFuncIndex == index) {
        store.setTdglFlag(false);
        store.setPoplayerListAction({});
        divPoint3 && divPoint3.deleteObject();
        store.setPoplayerShowAction(false);
        if (window.tdglLine) {
          sgworld.Creator.DeleteObject(window.tdglLine);
          window.tdglLine = null;
        }
        this.curFuncIndex = -1;
        window.clusterLayer && window.clusterLayer.clear();
        if (window.tdglLayer) {
          store.setSliderShow(false);
          sgworld.Creator.DeleteObject(window.tdglLayer);
        }
      } else {
        // éšè—åº•部图层面版
        store.setLayerPanelShow(false);
        // éšè—å³ä¸Šè§’菜单面板
        store.setMenuListShow(false);
        // éšè—åº•部漫游面板
        store.setRoamPanelShow(false);
        this.curFuncIndex = index;
        switch (index) {
          case 0:
            store.setSliderShow(true);
            window.tdglLayer = sgworld.Creator.createImageryProvider(
              layers[8].name,
              "tms",
              {
                id: layers[8].children[0].id,
                url: layers[8].children[0].urls,
                fileExtension: layers[8].children[0].img || "png",
                enablePickFeatures: false,
                level: layers[8].children[0].Level,
                minimumLevel: layers[8].children[0].minimumLevel,
                maximumLevel: layers[8].children[0].maximumLevel,
                tilingScheme:
                  layers[8].children[0].tileType === "Geo"
                    ? new Cesium.GeographicTilingScheme()
                    : new Cesium.WebMercatorTilingScheme(),
                // alpha: layers[8].children[0].alpha,
                alpha: this.alpha,
              },
              "0",
              layers[8].children[0].zIndex,
              true,
              ""
            );
            //显示滑动条
            store.setTdglFlag(true);
            break;
          case 1:
            this.curFuncIndex = -1;
            store.setTdglFlag(false);
            if (window.tdglLayer) {
              store.setSliderShow(false);
              sgworld.Creator.DeleteObject(window.tdglLayer);
            }
            store.setHistoryShow(true);
            break;
        }
      }
    },
    showLayerTree() {
      store.setLayerTreeShow(true);
    },
  },
  watch: {
    "state.itemId": {
      handler: function (newVal, oldVal) {
        let that = this;
        if (newVal == "") {
          this.curAreaTypeIndex = -1;
        } else {
          let index = -1;
          if (newVal == "GuiHuaFanWeiShiYiTu") {
            index = 0;
          } else if (newVal == "XingZhengQuHuaTu") {
            index = 1;
          } else if (newVal == "GuiHuaDanYuanHuaFenTu") {
            index = 2;
          } else if (newVal == "ZhuYaoGongNengQuGuiHuaShiYiTu") {
            index = 3;
          }
          this.curAreaTypeIndex = index;
        }
      },
    },
    // åŸºç¡€å›¾å±‚
    "basicMapChecked.val": {
      handler: function (newVal, oldVal) {
        if (newVal == "三维模型") {
          debugger;
          this.handleSMapClick(
            {
              id: "swmx",
              name: "三维模型",
              active: false,
              type: "san",
              src: require("@/assets/img/layer/swmx.png"),
            },
            1
          );
        }
      },
      immediate: true, //刷新加载 ç«‹é©¬è§¦å‘一次handler
      deep: true, // å¯ä»¥æ·±åº¦æ£€æµ‹åˆ° obj å¯¹è±¡çš„属性值的变化
    },
    // "state1.alpha": {
    //   handler: function (newVal) {
    //     this.handleFuncClick(0);
    //   },
    //   deep: true,
    // },
  },
  computed: {
    alpha() {
      return store.tdglInfo.alpha;
    },
  },
};
</script>
<style scoped>
.layerPanel {
  width: 100%;
  position: absolute;
  bottom: 0px;
  align-items: center;
  padding: 0.1rem;
  background: white;
  z-index: 1000;
  padding-left: 0.25rem;
}
.title {
  height: 25px;
  font-size: 16px;
  font-family: Source Han Sans SC;
  font-weight: 700;
  color: #181818;
  line-height: 25px;
  margin: 10px 0px 10px 0;
}
.title2 {
  height: 15px;
}
.container {
  display: flex;
  align-items: center;
  text-align: center;
}
.layerItem {
  /* font-size: 14px; */
  font-family: Source Han Sans SC;
  font-weight: 400;
  margin-right: 30px;
  cursor: pointer;
}
.active {
  color: #4187ff;
  border: 2px solid #4187ff;
  border-radius: 10px;
}
.spanActive {
  color: #4187ff;
}
img {
  display: block;
  width: 60px;
  height: 40px;
  margin-bottom: 5px;
}
.more {
  float: right;
  margin-right: 20px;
  font-size: 0.12rem;
  color: #4187ff;
  line-height: 25px;
  font-weight: 500;
  font-family: unset;
  cursor: pointer;
}
</style>
src/components/sideMenu/layerMenu/main2.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,20 @@
<template>
  <div v-show="state.show">
    <layerPanel></layerPanel>
  </div>
</template>
<script>
import store from "@/utils/store.js";
import layerPanel from "./layerPanel2.vue";
export default {
  components: {
    layerPanel,
  },
  data() {
    return {
      state: store.layerPanel,
    };
  },
};
</script>
src/components/viewer2.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,390 @@
<template>
  <div class="panel">
    <!-- openlayer -->
    <div id="openlayerContainer" @click="clicktoclose"></div>
    <!-- é¡µé¢æ ‡é¢˜ -->
    <div class="titleBg">
      <img src="@/assets/img/title/title.png" />
    </div>
    <!-- åŽ†å²å½±åƒ -->
    <!-- <my-history v-if="state.show"></my-history> -->
    <!-- åŽ†å²å½±åƒå…³é—­æŒ‰é’® -->
    <!-- <div class="colseBtn" v-if="state.show" @click="closeHistory(false)">
      <img class="searchBtn" src="@/assets/closeinput1.png" />
    </div> -->
    <!-- å³ä¾§å¯¼èˆªæ¡† -->
    <!-- <my-navigation-bar></my-navigation-bar> -->
    <!-- æœç´¢æ¡† -->
    <!-- <my-sousuo v-if="!state.show" v-show="childrendata.ssval"></my-sousuo> -->
    <!-- å³ä¸Šå¿«æ·åŒºåŸŸï¼ˆå·¥ç¨‹æ ‘、空间分析) -->
    <!-- <div class="right-top">
      <my-layertree :rightshowzy="childrendata"></my-layertree>
    </div> -->
    <!-- åŽŸå·¦ä¸‹èœå• -->
    <!-- <my-menu v-on:getshowsta="datafromchild" ref="menu"></my-menu> -->
    <!-- å·¦ä¸‹å¿«æ·åŒºåŸŸï¼ˆå¤ä½ã€æŒ‡åŒ—等) -->
    <!-- <my-left-bottom :test="childrendata"></my-left-bottom> -->
    <!-- å³ä¸‹å¿«æ·åŒºåŸŸï¼ˆæ”¾å¤§ç¼©å°ï¼‰ -->
    <!-- <my-right-bottom :test="childrendata"></my-right-bottom> -->
    <!-- å„种面板 -->
    <!-- è®¾ç½®é¢æ¿ -->
    <!-- <my-setting-panel></my-setting-panel> -->
    <!-- ä½ç½®é¢æ¿ -->
    <!-- <my-collection-panel></my-collection-panel> -->
    <!-- æŒ‡åŒ—针面板 -->
    <!-- <my-direction-panel></my-direction-panel> -->
    <!-- æ–°å¢žæ”¶è—é¢æ¿ -->
    <!-- <my-add-collection-panel></my-add-collection-panel> -->
    <!-- çª¨äº•、摄像头统计面板 -->
    <!-- <my-statistics-panel></my-statistics-panel> -->
    <!-- çª¨äº•统计分析面板 -->
    <!-- <my-manhole-panel></my-manhole-panel> -->
    <!-- æ‘„像头统计分析面板 -->
    <!-- <my-video-panel></my-video-panel> -->
    <!-- å›¾å±‚面板 -->
    <!-- <my-layer-panel></my-layer-panel> -->
    <!-- æ¼«æ¸¸é¢æ¿ -->
    <!-- <my-roam-panel></my-roam-panel> -->
    <!-- å›¾å±‚树面板 -->
    <!-- <my-layer-tree-panel></my-layer-tree-panel> -->
    <!-- åœŸåœ°ç®¡ç†å¼¹çª— -->
    <!-- <my-land-admin-info></my-land-admin-info>
    <my-slider></my-slider> -->
  </div>
</template>
<script>
import store from "@/utils/store.js";
import _GLOBAL from "@/assets/GLOBAL";
import { leftClick, loadLayer } from "@/utils/map.js";
import leftBottom from "@/components/leftMenu/bottom.vue";
import rightBottom from "@/components/rightMenu/bottom.vue";
import sousuo from "@/components/leftMenu/sousuo.vue";
import menu from "@/components/menu/menu.vue";
import NavigationBar from "./rightNavigation/NavigationBar.vue";
import layertree from "@/components/rightMenu/layerTree.vue";
import settingPanel from "./sideMenu/settingMenu/main.vue";
import collectionPanel from "./sideMenu/collectionMenu/main.vue";
import directionPanel from "./sideMenu/directionMenu/main.vue";
import addCollectionPanel from "./sideMenu/addCollectionMenu/main.vue";
import statisticsPanel from "./sideMenu/statisticsMenu/main.vue";
import manholePanel from "./sideMenu/manholeStatistics/main.vue";
import videoPanel from "./sideMenu/videoStatistics/main.vue";
import layerPanel from "./sideMenu/layerMenu/main2.vue";
import roamPanel from "./sideMenu/roamPanel/main.vue";
import layerTreePanel from "./sideMenu/layerTreePanel/main.vue";
import history from "./poplayer/history.vue";
import landAdminInfo from "./poplayer/landAdmin.vue";
import sliderAlpha from "./sideMenu/sliderAlpha/main.vue";
import Axios from "axios";
import Map from "ol/Map.js";
import TileLayer from "ol/layer/Tile.js";
import View from "ol/View.js";
import {
    get as getProjection,
    getTransform
} from 'ol/proj';
import {
    getWidth,
    getTopLeft,
    applyTransform
} from 'ol/extent';
import
    WMTS
 from 'ol/source/WMTS';
import WMTSTileGrid from 'ol/tilegrid/WMTS';
export default {
  name: "viewer2",
  components: {
    "my-sousuo": sousuo,
    "my-left-bottom": leftBottom,
    "my-right-bottom": rightBottom,
    "my-menu": menu,
    "my-layertree": layertree,
    "my-navigation-bar": NavigationBar,
    "my-setting-panel": settingPanel,
    "my-collection-panel": collectionPanel,
    "my-direction-panel": directionPanel,
    "my-add-collection-panel": addCollectionPanel,
    "my-statistics-panel": statisticsPanel,
    "my-manhole-panel": manholePanel,
    "my-video-panel": videoPanel,
    "my-layer-panel": layerPanel,
    "my-roam-panel": roamPanel,
    "my-layer-tree-panel": layerTreePanel,
    "my-history": history,
    "my-land-admin-info": landAdminInfo,
    "my-slider": sliderAlpha,
  },
  data() {
    return {
      date: "",
      parentItem: {},
      childrendata: {
        fwval: true,
        zbzval: false,
        qpval: false,
        zymlval: false,
        zymlmenu: false,
        kjcxval: false,
        dxmsval: false,
        snmsval: false,
        ssval: true,
        zoomval: true,
      },
      timer: null,
      count: 0,
      state: store.history,
    };
  },
  created() {},
  mounted() {
    this.$nextTick(function () {
      console.log('openlayer init');
      const layers = [];
      const TDTKey = 'f234b950740b8c2e0d9959a51c169d21';
      const tiandituUrl = 'http://t0.tianditu.gov.cn';
      let  options = {proj:'EPSG:4326',layer:'cia',matrixSets:"c"};
      let _proj = options.proj;
      let _layer = options.layer;
      let _key = TDTKey;
      let _matrixSets = options.matrixSets;
      let projection = getProjection(_proj);
      let projectionExtent = projection.getExtent();
      let origin = projectionExtent ? getTopLeft(projectionExtent) : [-180, 90];
      let fromLonLat = getTransform("EPSG:4326", projection);
      let width = projectionExtent
        ? getWidth(projectionExtent)
        : getWidth(applyTransform([-180.0, -90.0, 180.0, 90.0], fromLonLat));
      let resolutions = [];
      let matrixIds = [];
      for (let z = 1; z < 19; z++) {
        resolutions[z] = width / (256 * Math.pow(2, z));
        matrixIds[z] = z;
      }
      let wmtsTileGrid = new WMTSTileGrid({
        origin: origin,
        resolutions: resolutions,
        matrixIds: matrixIds,
      });
      console.log('url:',`${tiandituUrl}/${_layer}_${_matrixSets}/wmts?tk=${_key}`);
      let wmtsSource = new WMTS({
        url: `${tiandituUrl}/${_layer}_${_matrixSets}/wmts?tk=${_key}`,
        layer: _layer,
        version: "1.0.0",
        matrixSet: _matrixSets,
        format: "tiles",
        projection: projection,
        requestEncoding: "KVP",
        style: "default",
        tileGrid: wmtsTileGrid,
      });
      let wmtsLayer = new TileLayer({
        id: _layer + "_" + _matrixSets,
        source: wmtsSource,
      });
      let wmtsSource1 = new WMTS({
        url: `${tiandituUrl}/img_${_matrixSets}/wmts?tk=${_key}`,
        layer: 'img',
        version: "1.0.0",
        matrixSet: _matrixSets,
        format: "tiles",
        projection: projection,
        requestEncoding: "KVP",
        style: "default",
        tileGrid: wmtsTileGrid,
      });
      let wmtsLayer1 = new TileLayer({
        id: _layer + "_" + _matrixSets,
        source: wmtsSource1,
      });
      layers.push(wmtsLayer1);
      layers.push(wmtsLayer);
      const map = new Map({
        layers: layers,
        target: "openlayerContainer",
        view: new View({
          center: [-6655.5402445057125, 6709968.258934638],
          zoom: 12,
        }),
      });
      window.layerOpen = function (name, options) {
        layuiLayer.close(SmartEarthPopupData.layerProp);
        var width = options.width;
        var height = options.height;
        var offset = options.offset;
        var fn = options.fn || {};
        //获取相关回调事件
        var cancelFn = null;
        var successFn = null;
        var endFn = null;
        for (var key in fn) {
          cancelFn = key == "cancel" ? fn[key] : cancelFn;
          successFn = key == "success" ? fn[key] : successFn;
          endFn = key == "end" ? fn[key] : endFn;
        }
        SmartEarthPopupData.layerProp = layuiLayer.open({
          title: name,
          skin: "title-class",
          // title:false,
          type: 2, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
          // shade: options.shade !== undefined ? options.shade : 0.3,
          shade: 0,
          shadeClose: false,
          closeBtn: 1,
          resize: false,
          offset: offset,
          area: [
            typeof width === "number" ? width + "px" : width,
            // "100%",
            typeof height === "number" ? height + "px" : height,
          ],
          content: options.url,
          success: function (layero, index) {
            if (successFn && typeof successFn === "function") {
              successFn(layero, index);
            }
          },
          cancel: function () {
            if (cancelFn && typeof cancelFn === "function") {
              cancelFn();
            }
          },
          end: function () {
            if (endFn && typeof endFn === "function") {
              endFn();
            }
          },
        });
      };
    });
  },
  methods: {
    clicktoclose() {
      clearTimeout(this.timer);
      this.timer = setTimeout(() => {
        this.count++;
        if (this.count == 2) {
          // console.log("单击事件");
          // å…³é—­æ‰€æœ‰å¼¹çª—
          //this.$refs.menu.closeall();
          // æ¸…除定位中的位置标记
          //this.$refs.menu.clearFlyPoint();
        } else {
          // æ‰§è¡Œæ”¾å¤§æ“ä½œ
          // console.log("双击");
          // Viewer.camera.zoomIn();
          // console.log(window.clickPOI);
          let p = sgworld.Navigate.getDegrees();
          // console.log(p);
          Viewer.camera.flyTo({
            destination: Cesium.Cartesian3.fromDegrees(
              window.clickPOI.lon,
              window.clickPOI.lat,
              p.height / 1.8
            ),
            duration: 1.0,
          });
        }
        this.count = 0;
      }, 300);
      this.count++;
    },
    datafromchild(data) {
      for (var i in data) {
        this.childrendata[i] = data[i];
      }
    },
    closeHistory(val) {
      store.setHistoryShow(val);
    },
    showBottom() {
      let handler3D = new Cesium.ScreenSpaceEventHandler(Viewer.scene.canvas);
      handler3D.setInputAction((wheelment) => {
        // æ»šåŠ¨æ»šè½´ï¼Œå¾—åˆ°å½“å‰çš„è§†ç‚¹é«˜åº¦
        // å•位换算,当大于1000米的时候显示“千米”,小于1000米的时候显示单位为“米”
        var cHeightM = Viewer.camera.positionCartographic.height;
        var cHeightKm = (cHeightM / 1000).toFixed(0);
        // å½“cHeight的值改变时,赋值给window中的sdHeight
        window.sdHeight = this.cHeight;
        //当滑动的距离小于2km,取消聚合
        // if (window.dataClustering && window.dataClustering.enabled) {
        if (parseFloat(cHeightKm) < 2) {
          window.dataClustering && (window.dataClustering.enabled = false);
        } else {
          window.dataClustering && (window.dataClustering.enabled = true);
        }
      }, Cesium.ScreenSpaceEventType.WHEEL);
    },
    getQYInfo() {
      console.log(window.gisBaseUrl);
      Axios.get(
        window.gisBaseUrl +
          "/gisserver/wfsserver/qiyelianqiye?version=1.3.0&request=GetFeature&format=json&typename=企业链企业"
      ).then((res) => {
        console.log(res);
      });
    },
  },
};
</script>
<style scoped>
.panel,
#openlayerContainer {
  width: 100%;
  height: 100%;
  background: black;
  position: absolute !important;
}
.titleBg {
  position: absolute;
  left: 0rem;
  top: 0rem;
  width: 100%;
  height: 0.43rem;
  background-color: #127eff;
  text-align: center;
  /* background-image: url("~@/assets/img/title/u2.png") !important;
  background-repeat: no-repeat;
  background-size: 100% 100% !important; */
}
.titleBg img {
  width: 207px;
  margin-top: 5px;
}
.bottomLeft {
  display: none;
}
.colseBtn {
  position: absolute;
  z-index: 2;
  top: 0.55rem;
  left: 0.2rem;
}
.colseBtn img {
  width: 30px;
}
</style>
src/router/index.js
@@ -1,6 +1,7 @@
import Vue from 'vue'
import Router from 'vue-router'
import index from '@/components/viewer'
import index2 from '@/components/viewer2'
import login from '@/components/login'
Vue.use(Router)
@@ -21,6 +22,11 @@
    name: 'index',
    component: index
  },
  {
    path: '/index2',
    name: 'index2',
    component: index2
  },
];
const router = new Router({