北京经济技术开发区经开区虚拟城市项目-【前端】-移动端Web
lixuliang
2024-03-06 ec065c84d7ee0b7e05efe9b991b528f6a5feb5a0
src/components/sideMenu/layerMenu/layerPanel2.vue
@@ -1,7 +1,7 @@
<template>
  <div class="layerPanel">
    <div class="mapMode">
      <div class="title" style="margin-top: 0px">地图模式</div>
      <div class="title">地图模式</div>
      <div class="container">
        <div
          class="layerItem"
@@ -33,8 +33,8 @@
        </div>
      </div>
    </div>
    <div class="areaType" style="margin-top: 10px">
      <div class="title">
    <div class="areaType">
      <div class="title ZTtitle">
        专题应用
        <!-- 不显示更多图层 -->
        <span class="more" v-show="false" @click.stop="showLayerTree"
@@ -53,9 +53,6 @@
            ZTValue.name
          }}</span>
        </div>
      </div>
      <div class="title2"></div>
      <div class="container">
        <div
          class="layerItem"
          v-for="(funcValue, funcIndex) in FuncList"
@@ -71,6 +68,22 @@
          }}</span>
        </div>
      </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">
@@ -109,12 +122,15 @@
import store from "@/utils/store2.js";
import ZTTitem from "@/utils/ztt2.js";
import { layers } from "../../../../static/json/layer.js";
// import Tile from "ol/layer/Tile";
// import XYZ from "ol/source/XYZ";
// import { get as getProjection, getTransform } from "ol/proj";
// import { createXYZ } from "ol/tilegrid";
import {
  addImageLayer,
  addAnnotationLayer,
  addHxLayer,
  addYzLayer,
  loadBaseMap,
  loadGeoMap,
  clearAll,
} from "@/utils/tool";
export default {
  name: "LayerPanel",
  data() {
@@ -205,19 +221,19 @@
  },
  mounted() {
    this.$nextTick(() => {
      setTimeout(() => {
        this.handleEMapClick(
          {
            id: "yxdt",
            name: "影像地图",
            active: true,
            type: "er",
            src: "/static/img/yxdt.cf4698e.png",
          },
          1
        );
        loadEnterprise();
      }, 2000);
      // setTimeout(() => {
      //   this.handleEMapClick(
      //     {
      //       id: "yxdt",
      //       name: "影像地图",
      //       active: true,
      //       type: "er",
      //       src: "/static/img/yxdt.cf4698e.png",
      //     },
      //     1
      //   );
      //   loadEnterprise();
      // }, 2000);
    });
  },
  methods: {
@@ -253,36 +269,24 @@
    },
    // 二维底图选择
    handleEMapClick(result, index) {
      // 设置相机
      if (result.name == "二维地图") {
        window.map.getLayerByName("二维地图").setVisible(true);
        window.map.getLayerByName("影像地图").setVisible(false);
      } else if (result.name == "影像地图") {
        window.map.getLayerByName("影像地图").setVisible(true);
        window.map.getLayerByName("二维地图").setVisible(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]);
        });
      if (this.curEMapModelIndex == index) return;
      this.curEMapModelIndex = index;
      clearAll();
      switch (result.name) {
        case "二维地图":
          loadGeoMap();
          loadBaseMap();
          addAnnotationLayer();
          addHxLayer();
          addYzLayer();
          window.mapapi.getView().setZoom(14);
          break;
        case "影像地图":
          addImageLayer();
          addAnnotationLayer();
          addHxLayer();
          addYzLayer();
          break;
      }
    },
    // 三维模型选择
@@ -384,7 +388,7 @@
    },
    // 第二行 专题图 点击
    handleZTlick(result, index) {
      console.log(result, index);
      // console.log(result, index);
      const val = layers.filter((res) => {
        if (res.name == result.name) {
          return res;
@@ -405,73 +409,80 @@
      if (this.curFuncIndex == index) {
        store.setTdglFlag(false);
        store.setPoplayerListAction({});
        divPoint3 && divPoint3.deleteObject();
        store.setPoplayerShowAction(false);
        this.curFuncIndex = -1;
        // window.clusterLayer && window.clusterLayer.clear();
        if (window.tdglLine) {
          window.map.removeLayer(window.tdglLine);
          window.mapapi.removeLayer(window.tdglLine);
          window.tdglLine = null;
        }
        this.curFuncIndex = -1;
        window.clusterLayer && window.clusterLayer.clear();
        if (window.tdglLayer) {
        if (window.tdgllayer) {
          store.setSliderShow(false);
          window.map.removeLayer(window.tdglLayer);
          window.mapapi.removeLayer(window.tdgllayer);
          window.tdgllayer = null;
        }
      } else {
        this.curFuncIndex = index;
        // 隐藏底部图层面版
        store.setLayerPanelShow(false);
        // 隐藏右上角菜单面板
        store.setMenuListShow(false);
        // 隐藏底部漫游面板
        store.setRoamPanelShow(false);
        this.curFuncIndex = index;
        switch (index) {
          case 0:
            if (window.tdgllayer) {
              window.map.removeLayer(window.tdgllayer);
              store.setSliderShow(false);
              window.tdgllayer = null;
              window.map.removeLayer(window.tdglLine);
              return;
            }
            //显示滑动条
            store.setSliderShow(true);
            store.setTdglFlag(true);
            var url = layers[8].children[0].urls;
            //"https://skyzt.bda.gov.cn/gisserver/tmsserver/chengshiguihua_dikuaibianhao_tms/";
            window.map.removeLayer(window.tdgllayer);
            //加载地块模型
            window.tdgllayer = new ol.layer.Tile({
              source: new ol.source.XYZ({
                projection: "EPSG:4326",
                tileGrid: ol.tilegrid.createXYZ({
                  extent: [50.582, -90, 180, 70.1558],
                }),
                tileUrlFunction: function (tileCoord, pixelRatio, proj) {
                  // return url + (tileCoord[0] - 1) + '/' + tileCoord[1] + '/' + (Math.pow(2, tileCoord[0] - 1) + tileCoord[2]) + '.jpeg';
                  return (
                    url +
                    "/" +
                    (tileCoord[0] - 1) +
                    "/" +
                    tileCoord[1] +
                    "/" +
                    (Math.pow(2, tileCoord[0] - 1) + tileCoord[2]) +
                    ".jpeg"
                  );
              source: new ol.source.TileWMS({
                ratio: 3,
                url: "https://skyzt.bda.gov.cn/gisserver/wmsserver/chengshiguihua_dikuaibianhao",
                params: {
                  VERSION: "1.1.1",
                  SRS: "EPSG:4326",
                  FORMAT: "image/png",
                  TILED: true,
                  LAYERS: "",
                },
              }),
            });
            window.map.addLayer(window.tdgllayer);
            //显示滑动条
            store.setTdglFlag(true);
            // window.tdgllayer = new ol.layer.Tile({
            //   source: new ol.source.XYZ({
            //     projection: "EPSG:4326",
            //     format: new ol.format.MVT(),
            //     tileGrid: ol.tilegrid.createXYZ({
            //       // extent: [-50.582, -90, 180, 70.1558],
            //       extent: [-180, -90, 180, 90]
            //     }),
            //     tilePixelRatio: 3,
            //     tileUrlFunction: function (tileCoord, pixelRatio, proj) {
            //       console.log(tileCoord, '参数')
            //       console.log(Math.pow(2, tileCoord[0]) + tileCoord[2] - 1)
            //       // return url + (tileCoord[0] - 1) + '/' + tileCoord[1] + '/' + (Math.pow(2, tileCoord[0] - 1) + tileCoord[2]) + '.jpeg';
            //       return (
            //         url +
            //         (tileCoord[0]) +
            //         "/" +
            //         tileCoord[1] +
            //         "/" +
            //         (Math.pow(2, tileCoord[0]) + tileCoord[2] - 1) +
            //         ".jpeg"
            //       );
            //     },
            //   }),
            // });
            window.mapapi.addLayer(window.tdgllayer);
            break;
          case 1:
            this.curFuncIndex = -1;
            store.setTdglFlag(false);
            if (window.tdglLayer) {
              store.setSliderShow(false);
              window.map.removeLayer(window.tdgllayer);
            }
            store.setSliderShow(false);
            store.setHistoryShow(true);
            break;
        }
@@ -534,63 +545,100 @@
<style scoped>
.layerPanel {
  width: 100%;
  /* height: 396px; */
  position: absolute;
  bottom: 0px;
  align-items: center;
  padding: 0.1rem;
  background: white;
  /* padding: 0.1rem; */
  background: #ffffff;
  z-index: 1000;
  padding-left: 0.25rem;
  /* padding-left: 0.25rem; */
  border-radius: 15px 15px 0px 0px;
}
.mapMode {
  width: 100%;
  margin-top: 24px;
  padding-left: 28px;
}
.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;
@font-face {
  font-family: "YouSheBiaoTiHei";
  src: url("../../../../static/YouSheBiaoTiHei.ttf");
}
.title2 {
  height: 15px;
.title {
  width: 72px;
  height: 14px;
  font-family: "YouSheBiaoTiHei";
  font-weight: 400;
  font-size: 19px;
  color: #2e2e2e;
  line-height: 15px;
  margin-bottom: 18px;
}
.container {
  width: 100%;
  display: flex;
  align-items: center;
  text-align: center;
  flex-wrap: wrap;
}
.layerItem {
  /* font-size: 14px; */
  font-family: Source Han Sans SC;
  font-family: "微软雅黑";
  font-weight: 400;
  margin-right: 30px;
  cursor: pointer;
}
.mapMode .layerItem {
  width: 91px;
  margin-right: 24px;
}
.mapMode img {
  display: block;
  width: 91px;
  border-radius: 11px;
  border: 1px dashed #127dff;
  /* height: 40px; */
  margin-bottom: 11px;
}
span {
  font-family: "微软雅黑";
  font-weight: 500;
  font-size: 15px;
  color: #212121;
  line-height: 12px;
}
.active {
  color: #4187ff;
  border: 2px solid #4187ff;
  color: #127dff;
  border: 2px solid #127dff;
  border-radius: 10px;
}
.spanActive {
  color: #4187ff;
  color: #127dff;
}
img {
.areaType {
  width: 100%;
  margin-top: 30px;
}
.areaType .ZTtitle {
  margin-left: 28px;
  margin-bottom: 3px;
}
.areaType .container{
  padding: 0 18px 22px;
  justify-content: space-between;
}
.areaType img {
  display: block;
  width: 60px;
  height: 40px;
  margin-bottom: 5px;
  width: 84px;
}
.more {
  float: right;
  margin-right: 20px;
  font-size: 0.12rem;
  color: #4187ff;
  color: #127dff;
  line-height: 25px;
  font-weight: 500;
  font-family: unset;