From 5206e7a4f4c5b71c9ddeccdbbe5e7fba5b3eeb9b Mon Sep 17 00:00:00 2001 From: lixuliang <lixuliang_hd@126.com> Date: 星期五, 22 三月 2024 01:05:38 +0800 Subject: [PATCH] YOUHAU --- src/utils/map2.js | 59 ++++++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 40 insertions(+), 19 deletions(-) diff --git a/src/utils/map2.js b/src/utils/map2.js index 88b586d..9c152c7 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, @@ -2245,6 +2247,8 @@ //openlayer 鍦板浘鐐瑰嚮浜嬩欢 export function setClick(state) { function handleClick(e) { + let coordinate = ol.proj.toLonLat(e.coordinate) + // console.log(coordinate, '鍦板浘鐐瑰嚮') store.setLayerPanelShow(false); // 鍦熷湴绠$悊 if (store.tdglInfo.flag) { @@ -2253,9 +2257,9 @@ // "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 + "BEApi/cs/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 + "cs/geowinmap_xncs/ds?&lng=" + - e.coordinate[0] + + coordinate[0] + "&lat=" + - e.coordinate[1] + + coordinate[1] + "&geom=true&requesttype=json" ).then(response => { let center = { lon: 0, lat: 0 }; @@ -2264,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({ @@ -2369,21 +2376,23 @@ 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_; for (const propertyNames in properties) { if (propertyNames.indexOf("鐩戞帶鍚�") !== -1) { const infoM = Message({ - message: '璇ョ偣浣嶈棰戠洃鎺ф煡璇腑锛岃绋嶅悗', + message: '璇ョ偣浣嶈棰戠洃鎺у姞杞戒腑锛岃绋嶅悗', type: 'info', offset: 75, center: true, @@ -2394,7 +2403,10 @@ // 璇锋眰鍦ㄧ嚎鐘舵�� window.gisBaseUrl + "BEApi/getCameraDetails?cameraIndexCode=" + properties["JK鍐呯爜"] - ).then(res => { + , { + timeout: 6000 + }) + .then(res => { if (res.data.data.status == 1) { infoM.close(); Message({ @@ -2424,14 +2436,25 @@ } else { infoM.close(); Message({ - message: '璇ョ偣浣嶈棰戠洃鎺х绾夸腑', - type: 'errer', + message: '璇ヨ棰戠洃鎺х绾夸腑', + type: 'error', offset: 75, center: true, duration: 2000, }); return } + }) + .catch(err => { + infoM.close(); + Message({ + message: '璇ヨ棰戠洃鎺ц姹傝秴鏃�', + type: 'error', + offset: 75, + center: true, + duration: 2000, + }); + return }) return } else if (propertyNames.indexOf("閮ㄤ欢鍚嶇О") !== -1) { @@ -2472,10 +2495,6 @@ } } - - - - store.setTdglShow(false); store.setTdlgInfo({}); store.setdwShow(true); @@ -2493,8 +2512,9 @@ export function flyToPoint(posisitons) { window.mapapi.getView().animate({ - center: posisitons, - zoom: 15, + center: ol.proj.fromLonLat(posisitons), + projection: "EPSG:3857", + zoom: 18, duration: 1500 }) } @@ -2509,6 +2529,7 @@ if (len === 2) { window.mapapi.getView().animate({ center: window.mapapi.getView().getCenter(), + projection: "EPSG:3857", zoom: window.mapapi.getView().getZoom() - 1, duration: 1000, }); -- Gitblit v1.9.3