From 626003e9beb59cf711f59f3b48087300070f121e Mon Sep 17 00:00:00 2001
From: lixuliang <lixuliang_hd@126.com>
Date: 星期五, 15 三月 2024 09:49:31 +0800
Subject: [PATCH] 优化

---
 src/components/sideMenu/layerMenu/layerPanel2.vue |  402 ++++++++++++++++++++++++++++-----------------------------
 1 files changed, 196 insertions(+), 206 deletions(-)

diff --git a/src/components/sideMenu/layerMenu/layerPanel2.vue b/src/components/sideMenu/layerMenu/layerPanel2.vue
index e4c3a1c..510946f 100644
--- a/src/components/sideMenu/layerMenu/layerPanel2.vue
+++ b/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,32 +33,8 @@
         </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">
+    <div class="areaType">
+      <div class="title ZTtitle">
         涓撻搴旂敤
         <!-- 涓嶆樉绀烘洿澶氬浘灞� -->
         <span class="more" v-show="false" @click.stop="showLayerTree"
@@ -77,9 +53,6 @@
             ZTValue.name
           }}</span>
         </div>
-      </div>
-      <div class="title2"></div>
-      <div class="container">
         <div
           class="layerItem"
           v-for="(funcValue, funcIndex) in FuncList"
@@ -94,7 +67,24 @@
             funcValue.name
           }}</span>
         </div>
+        <!-- <div style="height: 0" class="layerItem" v-for="n in 3" :key="n"></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">
@@ -129,10 +119,19 @@
   clearLayerByTypeId,
   clearLayerByTypeIdArr,
 } from "@/utils/map.js";
-import _GLOBAL from "@/assets/GLOBAL";
-import store from "@/utils/store.js";
-import ZTTitem from "@/utils/ztt.js";
+import _GLOBAL from "@/assets/GLOBAL2";
+import store from "@/utils/store2.js";
+import ZTTitem from "@/utils/ztt2.js";
 import { layers } from "../../../../static/json/layer.js";
+import {
+  addImageLayer,
+  addAnnotationLayer,
+  addHxLayer,
+  addYzLayer,
+  loadBaseMap,
+  loadGeoMap,
+  clearAll,
+} from "@/utils/tool";
 export default {
   name: "LayerPanel",
   data() {
@@ -153,22 +152,7 @@
           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"),
-        // },
-      ],
+      sMapModelList: [],
       areaTypeList: [
         {
           id: "瑙勫垝鑼冨洿",
@@ -238,19 +222,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: {
@@ -286,54 +270,24 @@
     },
     // 浜岀淮搴曞浘閫夋嫨
     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) {
-        // 鍐嶆鐐瑰嚮閫変腑鐨刬tem鏃跺彇娑堥�夋嫨
-        // 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;
       }
     },
     // 涓夌淮妯″瀷閫夋嫨
@@ -435,6 +389,7 @@
     },
     // 绗簩琛� 涓撻鍥� 鐐瑰嚮
     handleZTlick(result, index) {
+      // console.log(result, index);
       const val = layers.filter((res) => {
         if (res.name == result.name) {
           return res;
@@ -443,38 +398,11 @@
       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);
       }
     },
     // 绗笁琛� 涓撻鍔熻兘 鐐瑰嚮
@@ -482,62 +410,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) {
-          sgworld.Creator.DeleteObject(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);
-          sgworld.Creator.DeleteObject(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:
-            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.setSliderShow(true);
             store.setTdglFlag(true);
+            var url = layers[8].children[0].urls;
+            //鍔犺浇鍦板潡妯″瀷
+            window.tdgllayer = new ol.layer.Tile({
+              source: new ol.source.TileWMS({
+                ratio: 3,
+                url: "https://skyzt.bda.gov.cn/gisserver/wmsserver/chengshiguihua_dikuaibianhao",
+                params: {
+                  VERSION: "1.1.1",
+                  SRS: "EPSG:3857",
+                  FORMAT: "image/png",
+                  TILED: true,
+                  LAYERS: "",
+                },
+              }),
+            });
+
+            // 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);
-              sgworld.Creator.DeleteObject(window.tdglLayer);
-            }
+            store.setSliderShow(false);
             store.setHistoryShow(true);
             break;
         }
@@ -588,12 +534,6 @@
       immediate: true, //鍒锋柊鍔犺浇 绔嬮┈瑙﹀彂涓�娆andler
       deep: true, // 鍙互娣卞害妫�娴嬪埌 obj 瀵硅薄鐨勫睘鎬у�肩殑鍙樺寲
     },
-    // "state1.alpha": {
-    //   handler: function (newVal) {
-    //     this.handleFuncClick(0);
-    //   },
-    //   deep: true,
-    // },
   },
   computed: {
     alpha() {
@@ -606,63 +546,113 @@
 <style scoped>
 .layerPanel {
   width: 100%;
+  /* height: 396px; */
   position: absolute;
   bottom: 0px;
   align-items: center;
-  padding: 0.1rem;
-  background: white;
-  z-index: 1000;
-  padding-left: 0.25rem;
+  /* padding: 0.1rem; */
+  background: #ffffff;
+  /* z-index: 1000; */
+  /* padding-left: 0.25rem; */
+  border-radius: 15px 15px 0px 0px;
+}
+.mapMode {
+  width: 100%;
+  margin-top: 24px;
+  padding-left: 28px;
 }
 
+@font-face {
+  font-family: "YouSheBiaoTiHei";
+  src: url("../../../../static/YouSheBiaoTiHei.ttf");
+}
 .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;
+  width: 72px;
+  height: 14px;
+  font-family: "YouSheBiaoTiHei";
+  font-weight: 400;
+  font-size: 19px;
+  color: #2e2e2e;
+  line-height: 15px;
+  margin-bottom: 18px;
 }
-.title2 {
-  height: 15px;
-}
-.container {
+.mapMode .container {
   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;
+  text-align: center;
 }
-
-.active {
-  color: #4187ff;
-  border: 2px solid #4187ff;
+.mapMode .layerItem {
+  width: 0.8rem;
+  margin-right: 24px;
+}
+.mapMode img {
+  display: block;
+  width: 100%;
+  border-radius: 11px;
+  border: 1px dashed #127dff;
+  margin-bottom: 11px;
+}
+span {
+  font-family: "寰蒋闆呴粦";
+  font-size: 0.12rem;
+  color: #6e6969;
+  line-height: 12px;
+}
+.mapMode .active,
+.areaType .active {
+  color: #127dff;
+  border: 2px solid #127dff;
   border-radius: 10px;
 }
 
 .spanActive {
-  color: #4187ff;
+  color: #127dff;
+}
+.areaType {
+  width: 100%;
+  margin-top: 30px;
 }
 
-img {
+.areaType .ZTtitle {
+  margin-left: 28px;
+  margin-bottom: 3px;
+}
+.areaType .container {
+  margin-top: 18px;
+  padding: 0 4%;
+  display: grid;
+  justify-items: center;
+  grid-template-columns: repeat(4, 1fr);
+  overflow: hidden;
+}
+.areaType .layerItem {
+  margin-bottom: 15px;
+}
+
+.areaType img {
+  margin: 0 auto;
+  /* background-color: green; */
   display: block;
-  width: 60px;
-  height: 40px;
-  margin-bottom: 5px;
+  width: 0.5rem;
+  border-radius: 11px;
+  box-shadow: 0 0 5px 5px rgb(196 222 236 / 30%);
+  margin-bottom: 11px;
 }
 
 .more {
   float: right;
   margin-right: 20px;
   font-size: 0.12rem;
-  color: #4187ff;
+  color: #127dff;
   line-height: 25px;
   font-weight: 500;
   font-family: unset;

--
Gitblit v1.9.3