diff --git a/packages/plugins/map/src/client/components/AMap/Block.tsx b/packages/plugins/map/src/client/components/AMap/Block.tsx index 982225607..8391a6439 100644 --- a/packages/plugins/map/src/client/components/AMap/Block.tsx +++ b/packages/plugins/map/src/client/components/AMap/Block.tsx @@ -137,7 +137,9 @@ export const AMapBlock = (props) => { return overlay; }); }) - .flat(); + .flat() + .filter(Boolean); + mapRef.current?.map?.setFitView(overlays); const events = overlays.map((o: AMap.Marker) => { diff --git a/packages/plugins/map/src/client/components/GoogleMaps/Block.tsx b/packages/plugins/map/src/client/components/GoogleMaps/Block.tsx index 8ea2bcc9c..bd9587155 100644 --- a/packages/plugins/map/src/client/components/GoogleMaps/Block.tsx +++ b/packages/plugins/map/src/client/components/GoogleMaps/Block.tsx @@ -173,7 +173,8 @@ export const GoogleMapsBlock = (props) => { return overlay; }); }) - .flat(); + .flat() + .filter(Boolean); overlaysRef.current = overlays; mapRef.current?.setFitView(overlays);