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