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/utils/map2.js |   28 +++++++++++++++-------------
 1 files changed, 15 insertions(+), 13 deletions(-)

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
     })
 }

--
Gitblit v1.9.3