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/viewer2.vue                        |    2 
 src/assets/GLOBAL2.vue                            |    2 
 src/components/leftMenu/sousuo.vue                |    6 
 src/components/rightMenu/bottom2.vue              |   22 +++--
 src/components/sideMenu/layerMenu/layerPanel2.vue |    4 
 src/components/poplayer/history2.vue              |   10 +-
 src/components/sideMenu/sliderAlpha/alpha2.vue    |    3 
 src/components/leftMenu/sousuo2.vue               |   64 ++++++++++++++--
 src/utils/tool.js                                 |   47 ++++++++++-
 src/utils/map2.js                                 |   28 +++---
 10 files changed, 142 insertions(+), 46 deletions(-)

diff --git a/src/assets/GLOBAL2.vue b/src/assets/GLOBAL2.vue
index 3053acc..5041c7e 100644
--- a/src/assets/GLOBAL2.vue
+++ b/src/assets/GLOBAL2.vue
@@ -8,6 +8,7 @@
 const hexin = null;
 const yzxcgh = null;
 const historyLayer = null;
+const historyLW = null;
 const rotate = 90;
 const GPSMarker = null;
 
@@ -21,6 +22,7 @@
   hexin,
   yzxcgh,
   historyLayer,
+  historyLW,
   rotate,
   GPSMarker
 };
diff --git a/src/components/leftMenu/sousuo.vue b/src/components/leftMenu/sousuo.vue
index 6a81383..07aeca6 100644
--- a/src/components/leftMenu/sousuo.vue
+++ b/src/components/leftMenu/sousuo.vue
@@ -282,7 +282,7 @@
       rectangle.maxy > 31.182515322 && (rectangle.maxy = 31.182515322);
       return `RECT(${rectangle.minx} ${rectangle.miny},${rectangle.maxx} ${rectangle.maxy})`;
     },
-    getPoi() {
+    getGdPoi() {
       axios
         .get(common.poiserve, {
           params: {
@@ -386,7 +386,7 @@
         this.poiList = [];
         switch (this.select) {
           case "鍏ㄩ儴":
-            this.getPoi();
+            this.getGdPoi();
             this.getData();
             // axios
             //   .all([
@@ -512,7 +512,7 @@
             //   );
             break;
           case "POI":
-            this.getPoi();
+            this.getGdPoi();
             break;
           case "鍦板潡":
             this.getData();
diff --git a/src/components/leftMenu/sousuo2.vue b/src/components/leftMenu/sousuo2.vue
index 9686f35..27dd400 100644
--- a/src/components/leftMenu/sousuo2.vue
+++ b/src/components/leftMenu/sousuo2.vue
@@ -5,7 +5,10 @@
       <span
         @click="ssjmxs"
         style="float: left; height: 100%; width: 80%; overflow: hidden"
-        ><i class="el-icon-search" style="padding: 0px 15px 0px 20px;font-size: 0.15rem;"></i
+        ><i
+          class="el-icon-search"
+          style="padding: 0px 15px 0px 20px; font-size: 0.15rem"
+        ></i
         >{{ syssval }}</span
       >
       <span
@@ -150,7 +153,6 @@
   width: 0.8rem;
   position: relative;
   font-size: 0.14rem;
-
 }
 .el-select:after {
   content: "";
@@ -209,7 +211,7 @@
   line-height: 20px;
 }
 .ssjg .addressBox {
-  text-indent: 27px;
+  margin-left: 27px;
   margin-top: 5px;
   color: #000;
   font-weight: 500;
@@ -349,7 +351,7 @@
       rectangle.maxy > 31.182515322 && (rectangle.maxy = 31.182515322);
       return `RECT(${rectangle.minx} ${rectangle.miny},${rectangle.maxx} ${rectangle.maxy})`;
     },
-    getPoi() {
+    getGdPoi() {
       axios
         .get(common.poiserve, {
           params: {
@@ -362,8 +364,6 @@
           },
         })
         .then((res) => {
-          // 楂樺痉
-          console.log("poiserve");
           if (res.data.status == "1") {
             res.data.pois &&
               res.data.pois
@@ -395,6 +395,54 @@
                     pname: val.province,
                     type: val.type,
                     typecode: val.typecode,
+                  };
+                  Allresults.push(obj);
+                });
+          }
+          this.total = Allresults.length;
+          this.poiList = Allresults;
+          this.showList = true;
+        });
+    },
+    getBdPoi() {
+      axios
+        .get(common.poiserve, {
+          params: {
+            request: "bdPoi",
+            query: this.poi_text,
+            output: "json",
+            coord: "cgcs2000",
+            page_num: 1,
+            page_size: 30,
+          },
+        })
+        .then((res) => {
+          console.log(res);
+          if (res.data.status == 0) {
+            res.data.results &&
+              res.data.results
+                .filter((item) => {
+                  var reg = new RegExp("[\\u4E00-\\u9FFF]+", "g");
+                  return (
+                    item.city.includes("鍖椾含") &&
+                    item.name.includes(this.poi_text)
+                  );
+                })
+                .forEach((val) => {
+                  let poiarr = val.location.split(",");
+                  let poi = {
+                    lon: parseFloat(poiarr[0]),
+                    lat: parseFloat(poiarr[1]),
+                  };
+                  let obj = {
+                    address: val.address,
+                    adname: val.area,
+                    cityname: val.city,
+                    id: val.uid,
+                    lat: val.location.lat,
+                    lng: val.location.lng,
+                    name: val.name,
+                    pname: val.province,
                   };
                   Allresults.push(obj);
                 });
@@ -454,7 +502,7 @@
         this.poiList = [];
         switch (this.select) {
           case "鍏ㄩ儴":
-            this.getPoi();
+            this.getBdPoi();
             this.getData();
             // axios
             //   .all([
@@ -580,7 +628,7 @@
             //   );
             break;
           case "POI":
-            this.getPoi();
+            this.getBdPoi();
             break;
           case "鍦板潡":
             this.getData();
diff --git a/src/components/poplayer/history2.vue b/src/components/poplayer/history2.vue
index 31b66f0..4b6fcc3 100644
--- a/src/components/poplayer/history2.vue
+++ b/src/components/poplayer/history2.vue
@@ -23,7 +23,7 @@
 <script>
 import _GLOBAL from "@/assets/GLOBAL";
 import store from "@/utils/store2";
-import { addHistoryLayer } from "@/utils/tool";
+import { addHistoryLayer, addHistoryLW } from "@/utils/tool";
 export default {
   name: "historyBox",
   components: {},
@@ -42,6 +42,7 @@
     window.mapapi.getView().setCenter(ol.proj.fromLonLat([4.606512, 2.621472]));
     // window.mapapi.getView().setCenter(ol.proj.fromLonLat([116.505348, 39.795592]));
     addHistoryLayer(this.currentValue);
+    addHistoryLW();
     if (_GLOBAL.GPSMarker) {
       window.mapapi.removeLayer(_GLOBAL.GPSMarker);
     }
@@ -54,7 +55,10 @@
     close() {
       store.setHistoryShow(false);
       window.mapapi.removeLayer(this.$global.historyLayer);
-      window.mapapi.getView().setCenter(ol.proj.fromLonLat([116.505348, 39.795592]));
+      window.mapapi.removeLayer(this.$global.historyLW);
+      window.mapapi
+        .getView()
+        .setCenter(ol.proj.fromLonLat([116.505348, 39.795592]));
       store.setNavigatorShow(true);
       store.setMapToolShow(true);
     },
@@ -102,8 +106,6 @@
   /* background-color: #00e1ff; */
   color: #127dff;
 }
-
-
 
 .listBox .active {
   /* background-color: #4590d7; */
diff --git a/src/components/rightMenu/bottom2.vue b/src/components/rightMenu/bottom2.vue
index 56874b4..b513f7a 100644
--- a/src/components/rightMenu/bottom2.vue
+++ b/src/components/rightMenu/bottom2.vue
@@ -1,10 +1,10 @@
 <template>
   <div class="bottom" id="bottom" :style="customStyle" v-if="state1.show">
-    <!-- <div class="mapTool">
-      <div class="tool-rotate" @click="PointingNorth" title="鎸囧寳">
+    <div class="mapTool">
+      <div class="tool-rotate" @click="flyToCurrentPosition" title="瀹氫綅">
         <img src="@/assets/img/collection/compass.png" />
       </div>
-    </div> -->
+    </div>
     <div class="mapTool">
       <div class="tool-rotate" @click="flyBack" title="澶嶄綅">
         <img src="@/assets/img/collection/recover.png" />
@@ -23,7 +23,6 @@
 </template>
 
 <style scoped>
-
 .mapTool {
   width: 0.42rem;
   /* border-radius: 10px; */
@@ -46,7 +45,7 @@
   align-items: center;
   justify-content: center;
 }
-.mapTool2 .tool-rotate{
+.mapTool2 .tool-rotate {
   height: 0.33rem;
   line-height: 0.33rem;
 }
@@ -78,7 +77,7 @@
       },
     };
   },
-  mounted() { },
+  mounted() {},
   watch: {
     "state.show": {
       handler(newVal) {
@@ -131,9 +130,14 @@
         duration: 1000, // 缂╂斁鎸佺画鏃堕棿锛岄粯璁や笉闇�瑕佽缃�
       });
     },
-    PointingNorth() {
-      alert("鎸囧寳閽堝紑鍙戜腑");
-      // console.log("鎸囧寳閽堝紑鍙戜腑")
+    flyToCurrentPosition() {
+      window.mapapi.getView().animate({
+        // 鍙缃渶瑕佺殑灞炴�у嵆鍙�
+        center: window.personalPoi, // 涓績鐐�
+        zoom: 17, // 缂╂斁绾у埆
+        rotation: undefined, // 缂╂斁瀹屾垚view瑙嗗浘鏃嬭浆寮у害
+        duration: 1500, // 缂╂斁鎸佺画鏃堕棿锛岄粯璁や笉闇�瑕佽缃�
+      });
     },
   },
 };
diff --git a/src/components/sideMenu/layerMenu/layerPanel2.vue b/src/components/sideMenu/layerMenu/layerPanel2.vue
index 4848bbb..510946f 100644
--- a/src/components/sideMenu/layerMenu/layerPanel2.vue
+++ b/src/components/sideMenu/layerMenu/layerPanel2.vue
@@ -276,11 +276,11 @@
       switch (result.name) {
         case "浜岀淮鍦板浘":
           loadGeoMap();
-          loadBaseMap();
+          // loadBaseMap();
           // addAnnotationLayer();
           addHxLayer();
           addYzLayer();
-          window.mapapi.getView().setZoom(14);
+          // window.mapapi.getView().setZoom(14);
           break;
         case "褰卞儚鍦板浘":
           addImageLayer();
diff --git a/src/components/sideMenu/sliderAlpha/alpha2.vue b/src/components/sideMenu/sliderAlpha/alpha2.vue
index fcf62c8..98931ec 100644
--- a/src/components/sideMenu/sliderAlpha/alpha2.vue
+++ b/src/components/sideMenu/sliderAlpha/alpha2.vue
@@ -15,7 +15,8 @@
   methods: {
     changeSlider(val) {
       if (window.tdgllayer) {
-        window.tdgllayer.state_.layer.setOpacity(val / 100);
+        window.tdgllayer.state_ &&
+          window.tdgllayer.state_.layer.setOpacity(val / 100);
       }
     },
   },
diff --git a/src/components/viewer2.vue b/src/components/viewer2.vue
index aac3987..78e42f2 100644
--- a/src/components/viewer2.vue
+++ b/src/components/viewer2.vue
@@ -275,7 +275,7 @@
       // addAnnotationLayer();
       window.mapapi.getView().setZoom(14);
       loadGeoMap();
-      loadBaseMap();
+      // loadBaseMap();
       addHxLayer();
       addYzLayer();
 
diff --git a/src/utils/map2.js b/src/utils/map2.js
index 2a78f53..f701baf 100644
--- a/src/utils/map2.js
+++ b/src/utils/map2.js
@@ -2207,8 +2207,10 @@
 //openlayer 鍒涘缓鐐逛綅
 window.pointArr = [];
 export function createPointMarker(position, obj) {
+    let positions = ol.proj.fromLonLat(position);
     let startFeature = new ol.Feature({
-        geometry: new ol.geom.Point(position),
+        geometry: new ol.geom.Point(positions),
+
     });
     startFeature.setProperties({
         desc: obj,
@@ -2266,7 +2268,10 @@
                         window.tdglLine = null;
                     }
                     var format = new ol.format.WKT(); // 鍒涘缓涓�涓� WKT 瑙f瀽鍣�
-                    var feature = format.readFeature(response.data.geometry); // 瑙f瀽 WKT 骞剁敓鎴愯绱犲璞�
+                    var feature = format.readFeature(response.data.geometry, {
+                        dataProjection: 'EPSG:4326',
+                        featureProjection: 'EPSG:3857'
+                    }); // 瑙f瀽 WKT 骞剁敓鎴愯绱犲璞�
 
                     // 鍒涘缓涓�涓绱犲浘灞�
                     window.tdglLine = new ol.layer.Vector({
@@ -2371,14 +2376,15 @@
 
         window.mapapi.forEachFeatureAtPixel(e.pixel, function (feature) {
             console.log(feature.getProperties(), 'aaa');
-
             //鎼滅储鐨勭偣浣�
             if (window.pointArr.length > 0) {
                 let obj = feature.getProperties().desc
-                objdata = {
-                    POITYPE: "POINT",
-                    name: obj.name,
-                    address: obj.address,
+                if (obj) {
+                    objdata = {
+                        POITYPE: "POINT",
+                        name: obj.name,
+                        address: obj.address,
+                    }
                 }
             } else {
                 let properties = feature.getProperties().features[0].values_;
@@ -2474,10 +2480,6 @@
                 }
             }
 
-
-
-
-
             store.setTdglShow(false);
             store.setTdlgInfo({});
             store.setdwShow(true);
@@ -2495,8 +2497,8 @@
 
 export function flyToPoint(posisitons) {
     window.mapapi.getView().animate({
-        center: posisitons,
-        zoom: 15,
+        center: ol.proj.fromLonLat(posisitons),
+        zoom: 18,
         duration: 1500
     })
 }
diff --git a/src/utils/tool.js b/src/utils/tool.js
index e4384d4..736d888 100644
--- a/src/utils/tool.js
+++ b/src/utils/tool.js
@@ -1,7 +1,7 @@
 
 import _GLOBAL from '@/assets/GLOBAL2'
 import gcj02Mecator from '@/utils/transform'
-import { ceil } from 'lodash';
+
 //娓呴櫎
 export function clearAll() {
     if (_GLOBAL.ImageLayer) {
@@ -30,8 +30,8 @@
     _GLOBAL.ImageLayer = new ol.layer.Tile({
         source: new ol.source.XYZ({
             url: `${'https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer'}/tile/{z}/{y}/{x}`,
-            projection:"EPSG:3857",
-            tileSize: 512        
+            projection: "EPSG:3857",
+            tileSize: 512
         }),
     });
     // window.mapapi.addLayer(_GLOBAL.ImageLayer);
@@ -128,11 +128,45 @@
     }
     _GLOBAL.historyLayer = new ol.layer.Tile({
         source: new ol.source.XYZ({
-            projection:"EPSG:3857",
+            projection: "EPSG:3857",
             url: `https://skyzt.bda.gov.cn/yzAdapter/Vector/?request=1&year=${layerName}&type=Sate&level={z}&x={x}&y={y}`,
         })
     });
     window.mapapi.addLayer(_GLOBAL.historyLayer);
+}
+var topResolution = 896.0859375;
+var resolutions = [];
+let matrixIds = [];
+
+for (let zoom = 0; zoom < 13; zoom++) {
+    resolutions.push(topResolution / Math.pow(2, zoom));
+    matrixIds[zoom] = zoom;
+}
+// 
+// 鍔犺浇鍘嗗彶褰卞儚璺綉
+export function addHistoryLW(name) {
+    const layerName = name;
+    if (_GLOBAL.historyLW) {
+        window.mapapi.removeLayer(_GLOBAL.historyLW)
+    }
+
+    _GLOBAL.historyLW = new ol.layer.Tile({
+        source: new ol.source.WMTS({
+            url: "https://skyzt.bda.gov.cn/service/ImageEngine/picdis/abc?",
+            layer: "Shiliang_Lw_2019",
+            style: "",
+            format: "image/png",
+            // 鎶曞奖鍧愭爣绯�
+            tileGrid: new ol.tilegrid.WMTS({
+                extent: [371987.18334, 252920.58593, 624459.12036, 423400.07714],
+                origin: [0, 688194],
+                resolutions: resolutions,
+                matrixIds: matrixIds,
+                tileSize: 256,
+            }),
+        }),
+    });
+    window.mapapi.addLayer(_GLOBAL.historyLW);
 }
 
 //瀹炴椂鑾峰彇瀹氫綅
@@ -154,12 +188,15 @@
 
 //鍒涘缓褰撳墠瀹氫綅鐐�
 export function createGPSMarker(position, rotate) {
+    let GPSPOI_3857 = ol.proj.fromLonLat(position);
+    // 璁板綍褰撳墠浣嶇疆(瀹氫綅鐢�)
+    window.personalPoi = GPSPOI_3857;
     const GPSMarkerLayer = new ol.layer.Vector({
         id: 'LocationPoint',
         name: '瀹氫綅鐐�',
         source: new ol.source.Vector({
             features: [new ol.Feature({
-                geometry: new ol.geom.Point(position),
+                geometry: new ol.geom.Point(GPSPOI_3857),
             })]
         }),
         style: new ol.style.Style({

--
Gitblit v1.9.3