From f7ab8838f095134c65d2628fe54a6fb8c5df146e Mon Sep 17 00:00:00 2001
From: 少年 <1392120328@qq.com>
Date: 星期三, 07 二月 2024 16:52:38 +0800
Subject: [PATCH] 111

---
 src/utils/map2.js |  198 +++++++++++++++++++++++++++++++++++-------------
 1 files changed, 143 insertions(+), 55 deletions(-)

diff --git a/src/utils/map2.js b/src/utils/map2.js
index 19e3c86..b86cdb5 100644
--- a/src/utils/map2.js
+++ b/src/utils/map2.js
@@ -2203,6 +2203,7 @@
 
 
 //openlayer 鍒涘缓鐐逛綅
+window.pointArr = [];
 export function createPointMarker(position, obj) {
     let startFeature = new ol.Feature({
         geometry: new ol.geom.Point(position),
@@ -2210,6 +2211,12 @@
     startFeature.setProperties({
         desc: obj,
     });
+    if (window.pointArr && window.pointArr.length > 0) {
+        window.pointArr.forEach(item => {
+            window.mapapi.removeLayer(item)
+        })
+        window.pointArr = []
+    }
     let MarkerLayer = new ol.layer.Vector({
         id: 'LocationPoint',
         name: '鏍囪鐐�',
@@ -2229,55 +2236,153 @@
         }),
         zIndex: 1099,
     })
+    window.pointArr.push(MarkerLayer)
     return MarkerLayer;
 }
 
 //openlayer 鍦板浘鐐瑰嚮浜嬩欢
 export function setClick(state) {
-    let ponitPanel = document.getElementById('ponitPanel');
-    let overlay = new ol.Overlay({
-        element: ponitPanel,
-        autoPan: {
-            animation: {
-                duration: 250,
-            },
-        },
-    });
-    window.map.addOverlay(overlay);
-
-    // let _clickCallback = callback;
     function handleClick(e) {
-        window.map.forEachFeatureAtPixel(e.pixel, function (feature) {
-            // console.log(feature, '111111')
-            if (feature && feature.values_.desc) {
-                ponitPanel.style.display = 'block'
 
+        console.log(e,'111')
+
+        store.setLayerPanelShow(false);
+
+        // 鍦熷湴绠$悊
+        if (store.tdglInfo.flag) {
+            axios
+                .get(
+                    // "http://10.10.4.115:8022/geowinmap_xncs/ds?r=0.9158559377752831&serviceproviderid=map.vectorserviceprovider&serviceid=queryfeature&featcls=225%25E8%258C%2583%25E5%259B%25B4%25E5%2588%2586%25E5%258C%25BA%25E8%25A7%2584%25E5%2588%2592.geojson&lng=" +
+                    window.gisBaseUrl + "yzxncsApi/geowinmap_xncs/ds?r=0.9158559377752831&serviceproviderid=map.vectorserviceprovider&serviceid=queryfeature&featcls=225%25E8%258C%2583%25E5%259B%25B4%25E5%2588%2586%25E5%258C%25BA%25E8%25A7%2584%25E5%2588%2592.geojson&lng=" +
+                    e.coordinate[0] +
+                    "&lat=" +
+                    e.coordinate[1] +
+                    "&geom=true&requesttype=json"
+                ).then(response => {
+                    let center = { lon: 0, lat: 0 };
+                    if (window.tdglLine) {
+                        window.mapapi.removeLayer(window.tdglLine);
+                        window.tdglLine = null;
+                    }
+                    var format = new ol.format.WKT(); // 鍒涘缓涓�涓� WKT 瑙f瀽鍣�
+                    var feature = format.readFeature(response.data.geometry); // 瑙f瀽 WKT 骞剁敓鎴愯绱犲璞�
+
+                    // 鍒涘缓涓�涓绱犲浘灞�
+                    window.tdglLine = new ol.layer.Vector({
+                        source: new ol.source.Vector({
+                            features: [feature] // 灏嗚绱犲璞″姞鍏ュ埌鍥惧眰婧愪腑
+                        })
+                    });
+                    window.mapapi.addLayer(window.tdglLine)
+
+
+                    axios
+                        .get(
+                            // "http://10.10.4.115:8022//poisearch/guihuacon/getInfo?ydbm=" +
+                            window.gisBaseUrl + "yzxncsApi/poisearch/guihuacon/getInfo?ydbm=" +
+                            response.data.NO
+                        )
+                        .then(
+                            info => {
+                                let data = info.data.data;
+                                if (data.yongdishuju === null) {
+                                    objdata = {
+                                        POITYPE: "NOTDGL",
+                                        zwxx: "鏆傛棤淇℃伅",
+                                        lon: window.clickPOI.lon,
+                                        lat: window.clickPOI.lat,
+                                    }
+                                } else {
+                                    qiyexinxi = info.data.data.qiyexinxi;
+                                    qysl = data.qiyexinxi.length;
+                                    if (qysl > 0) {
+                                        ydbm = data.qiyexinxi[0]["鍦板潡缂栧彿"];
+                                    } else {
+                                        ydbm = data.churangxinxi["ydbh"];
+                                    }
+                                    try {
+                                        ydlx = data.yongdishuju["ydlxmc"];
+                                    } catch (e) { }
+                                    try {
+                                        cyfx = data.yongdishuju["cyfx"];
+                                    } catch (e) { }
+                                    try {
+                                        // this.crzt = response.data["ZT"];
+                                        switch (response.data["ZT"]) {
+                                            case 3:
+                                                crzt = "宸插嚭璁�";
+                                                break;
+                                            case 4:
+                                                crzt = "鏈嚭璁�";
+                                                break;
+                                        }
+                                    } catch (e) { }
+                                    try {
+                                        ydmj = parseFloat(
+                                            "" + data.yongdishuju["ydmj"]
+                                        ).toFixed(0);
+                                    } catch (e) { }
+                                    try {
+                                        crnx = data.churangxinxi["crnx"];
+                                    } catch (e) { }
+                                    try {
+                                        crnf = data.churangxinxi["crnf"];
+                                    } catch (e) { }
+                                    try {
+                                        rjl = data.yongdishuju["rjl"];
+                                    } catch (e) { }
+                                    try {
+                                        jzxg = data.yongdishuju["jzxg"];
+                                    } catch (e) { }
+                                    try {
+                                        jzmd = data.yongdishuju["jzmd"];
+                                    } catch (e) { }
+                                    objdata = {
+                                        POITYPE: "TDGL",
+                                        ydbm,
+                                        ydlx,
+                                        cyfx,
+                                        crzt,
+                                        ydmj,
+                                        ydbm,
+                                        crnx,
+                                        crnf,
+                                        rjl,
+                                        jzxg,
+                                        jzmd,
+                                        lon: e.coordinate[0],
+                                        lat: e.coordinate[1],
+                                    }
+                                }
+
+                                store.setTdglShow(false);
+                                store.setTdlgInfo({});
+                                store.setTdglShow(true);
+                                store.setTdlgInfo(objdata);
+                            }
+                        );
+
+                })
+            return;
+        }
+
+        window.mapapi.forEachFeatureAtPixel(e.pixel, function (feature) {
+
+            console.log(feature,'feature')
+            if (feature && feature.values_.desc) {
                 let obj = feature.values_.desc
                 objdata = {
                     POITYPE: "POINT",
                     name: obj.name,
                     address: obj.address,
-                    lon: obj.lng,
-                    lat: obj.lat
+                    // lon: obj.lng,
+                    // lat: obj.lat
                 }
 
-
-                ponitPanel.innerHTML = `
-                       <div class="ponitPanel-name">
-                         <span>鍚嶇О锛�</span>
-                         <span>${objdata.name}</span>
-                       </div>
-                     <div class="ponitPanel-value"> 
-                        <span>鍦板潃锛�</span>
-                       <span>${objdata.address}</span>
-                    </div>`
-
-                setTimeout(() => {
-                    overlay.setPosition(e.coordinate);
-                }, 0)
-
-                // store.setPoplayerShowAction(true);
-                // store.setPoplayerListAction(objdata);
+                store.setTdglShow(false);
+                store.setTdlgInfo({});
+                store.setdwShow(true);
+                store.setdwInfo(objdata);
                 // if (window.instance) {
                 //     window.instance.$destroy();
                 // }
@@ -2291,7 +2396,7 @@
         });
     }
     if (state) {
-        clickEvent = window.map.on('click', handleClick);
+        clickEvent = window.mapapi.on('click', handleClick);
     } else {
         ol.Observable.unByKey(clickEvent)
         clickEvent = null
@@ -2300,26 +2405,9 @@
 
 
 export function flyToPoint(posisitons) {
-    // let zoom = window.map.getView().getZoom();
-    // if (zoom >= 16) {
-    //     zoom = 12
-    // }
-    // let duration = 2000;
-    window.map.getView().animate({
+    window.mapapi.getView().animate({
         center: posisitons,
-        zoom: 12,
+        zoom: 15,
         duration: 1500
     })
-    // window.map.getView().animate(
-    //     //鍔ㄧ敾寮�濮嬫椂
-    //     {
-    //         zoom: zoom > 16 ? zoom - 0.01 : zoom + 0.01,
-    //         duration: duration / 2,
-    //     },
-    //     //鍔ㄧ敾缁撴潫鏃�
-    //     {
-    //         zoom: zoom >= 16 ? 16 : zoom + 4,
-    //         duration: duration / 2,
-    //     }
-    // );
 }
\ No newline at end of file

--
Gitblit v1.9.3