From 6e49f62affe3367cfd3a4201af867542f49ae73b Mon Sep 17 00:00:00 2001 From: zyh Date: Fri, 11 Apr 2025 06:05:26 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9C=B0=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=E8=AE=B0=E7=82=B9=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=E6=A0=87=E8=AE=B0=E7=82=B9=E6=95=B0?= =?UTF-8?q?=E7=BB=84=E7=9A=84=E6=9C=89=E6=95=88=E6=80=A7=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=EF=BC=8C=E7=A1=AE=E4=BF=9D=E6=B8=B2=E6=9F=93=E6=97=B6=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=9A=84=E6=AD=A3=E7=A1=AE=E6=80=A7=EF=BC=8C=E6=8F=90?= =?UTF-8?q?=E5=8D=87=E4=BB=A3=E7=A0=81=E5=8F=AF=E7=BB=B4=E6=8A=A4=E6=80=A7?= =?UTF-8?q?=E5=92=8C=E7=94=A8=E6=88=B7=E4=BD=93=E9=AA=8C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/admin/components_amap.tsx | 12 +++++++----- client/admin/pages_map.tsx | 8 +++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/client/admin/components_amap.tsx b/client/admin/components_amap.tsx index d3fa203..fc0cb3e 100644 --- a/client/admin/components_amap.tsx +++ b/client/admin/components_amap.tsx @@ -308,7 +308,7 @@ export const useAMapMarkers = ({ }; useEffect(() => { - if (!map) return; + if (!map || !Array.isArray(markers)) return; // 清理旧的标记点和聚合点 if (clusterInstance.current) { @@ -319,10 +319,12 @@ export const useAMapMarkers = ({ markersRef.current = []; // 根据配置添加新的标记点 - if (showCluster) { - handleCluster(); - } else { - handleMarkers(); + if (markers.length > 0) { + if (showCluster) { + handleCluster(); + } else { + handleMarkers(); + } } return () => { diff --git a/client/admin/pages_map.tsx b/client/admin/pages_map.tsx index 2d1e9a2..6d13eee 100644 --- a/client/admin/pages_map.tsx +++ b/client/admin/pages_map.tsx @@ -107,9 +107,11 @@ export const LoginMapPage = () => { }; // 渲染地图标记点 - const renderMarkers = (locations: LoginLocation[]): MarkerData[] => { + const renderMarkers = (locations: LoginLocation[] = []): MarkerData[] => { + if (!Array.isArray(locations)) return []; + return locations - .filter(location => location.longitude !== null && location.latitude !== null) + .filter(location => location?.longitude !== null && location?.latitude !== null) .map(location => ({ id: location.id?.toString() || '', longitude: location.longitude as number, @@ -157,7 +159,7 @@ export const LoginMapPage = () => {