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 |   51 +++++++++++++++++++++++++++------------------------
 1 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/src/utils/map2.js b/src/utils/map2.js
index 219f65c..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,24 +2236,18 @@
         }),
         zIndex: 1099,
     })
+    window.pointArr.push(MarkerLayer)
     return MarkerLayer;
 }
 
 //openlayer 鍦板浘鐐瑰嚮浜嬩欢
 export function setClick(state) {
-    console.log('setClick');
-    let ponitPanel = document.getElementById('ponitPanel');
-    let overlay = new ol.Overlay({
-        element: ponitPanel,
-        autoPan: {
-            animation: {
-                duration: 250,
-            },
-        },
-    });
-    window.map.addOverlay(overlay);
     function handleClick(e) {
-        console.log(e.coordinate);
+
+        console.log(e,'111')
+
+        store.setLayerPanelShow(false);
+
         // 鍦熷湴绠$悊
         if (store.tdglInfo.flag) {
             axios
@@ -2260,7 +2261,7 @@
                 ).then(response => {
                     let center = { lon: 0, lat: 0 };
                     if (window.tdglLine) {
-                        window.map.removeLayer(window.tdglLine);
+                        window.mapapi.removeLayer(window.tdglLine);
                         window.tdglLine = null;
                     }
                     var format = new ol.format.WKT(); // 鍒涘缓涓�涓� WKT 瑙f瀽鍣�
@@ -2272,7 +2273,7 @@
                             features: [feature] // 灏嗚绱犲璞″姞鍏ュ埌鍥惧眰婧愪腑
                         })
                     });
-                    window.map.addLayer(window.tdglLine)
+                    window.mapapi.addLayer(window.tdglLine)
 
 
                     axios
@@ -2349,7 +2350,7 @@
                                         rjl,
                                         jzxg,
                                         jzmd,
-                                        lon:e.coordinate[0],
+                                        lon: e.coordinate[0],
                                         lat: e.coordinate[1],
                                     }
                                 }
@@ -2365,21 +2366,23 @@
             return;
         }
 
+        window.mapapi.forEachFeatureAtPixel(e.pixel, function (feature) {
 
-        window.map.forEachFeatureAtPixel(e.pixel, function (feature) {
+            console.log(feature,'feature')
             if (feature && feature.values_.desc) {
-                ponitPanel.style.display = 'block'
                 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
                 }
-                overlay.setPosition(e.coordinate);
-                store.setPoplayerShowAction(true);
-                store.setPoplayerListAction(objdata);
+
+                store.setTdglShow(false);
+                store.setTdlgInfo({});
+                store.setdwShow(true);
+                store.setdwInfo(objdata);
                 // if (window.instance) {
                 //     window.instance.$destroy();
                 // }
@@ -2393,7 +2396,7 @@
         });
     }
     if (state) {
-        clickEvent = window.map.on('click', handleClick);
+        clickEvent = window.mapapi.on('click', handleClick);
     } else {
         ol.Observable.unByKey(clickEvent)
         clickEvent = null
@@ -2402,7 +2405,7 @@
 
 
 export function flyToPoint(posisitons) {
-    window.map.getView().animate({
+    window.mapapi.getView().animate({
         center: posisitons,
         zoom: 15,
         duration: 1500

--
Gitblit v1.9.3