From d37391008115dba607c1763c77090a1da1291c2c Mon Sep 17 00:00:00 2001 From: qingzhengli <1204552371@qq.com> Date: Wed, 28 Feb 2024 14:17:57 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=20=E6=B8=85=E9=99=A4=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=E5=8D=A1=E6=AD=BBbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/RoadAndEvents/utils/map.js | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/RoadAndEvents/utils/map.js b/ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/RoadAndEvents/utils/map.js index 3e7e50d2..fad6ccbc 100644 --- a/ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/RoadAndEvents/utils/map.js +++ b/ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/RoadAndEvents/utils/map.js @@ -202,32 +202,34 @@ export class MarkerCluster { } = markerData; const lngLatStr = `${lng}/${lat}`; - context.marker.setContent(getContent(lngLatMap[lngLatStr])); + if (lngLatMap[lngLatStr]) { + context.marker.setContent(getContent(lngLatMap[lngLatStr])); - context.marker.setAnchor("bottom-center"); + context.marker.setAnchor("bottom-center"); - const offset = new AMap.Pixel(0, 0); - context.marker.setOffset(offset); + const offset = new AMap.Pixel(0, 0); + context.marker.setOffset(offset); - context.marker.setExtData(extData); + context.marker.setExtData(extData); - context.marker.on("click", (e) => { - hasClick = true; + context.marker.on("click", (e) => { + hasClick = true; - const data = lngLatMap[lngLatStr]; - if (data.length > 1) { - this.showInfoWindow(data); - return; - } + const data = lngLatMap[lngLatStr]; + if (data.length > 1) { + this.showInfoWindow(data); + return; + } - console.log( - "%c [ 点击地图坐标 ]-302-「map.js」", - "font-size:15px; background:#8f8c0b; color:#d3d04f;", - data[0] - ); + console.log( + "%c [ 点击地图坐标 ]-302-「map.js」", + "font-size:15px; background:#8f8c0b; color:#d3d04f;", + data[0] + ); - data[0].config.markerClick?.(data[0].extData, data[0].config?.item); - }); + data[0].config.markerClick?.(data[0].extData, data[0].config?.item); + }); + } }, }); @@ -321,6 +323,7 @@ function getIcon({ config, extData }) { } function getState(data) { + console.log(data, Array.isArray(data), "getState"); if (Array.isArray(data)) { return data.every((item) => getStateSingle(item)); } else return getStateSingle(data);