From 688946a6b8a476293ed56dd612f79a37a5c1d0ce Mon Sep 17 00:00:00 2001 From: Reynold Mok <34395415+reyery@users.noreply.github.com> Date: Thu, 13 Jun 2024 18:45:43 +0200 Subject: [PATCH] Fix camera due to undefined bounds --- src/components/Map/Map.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Map/Map.jsx b/src/components/Map/Map.jsx index 912e35d..03f82da 100644 --- a/src/components/Map/Map.jsx +++ b/src/components/Map/Map.jsx @@ -65,9 +65,9 @@ const DeckGLMap = ({ data, colors }) => { // Calculate total bounds with other geometries let bboxPoly = bboxPolygon(calcBbox(zone)); - if (data?.surroundings !== null) + if (data?.surroundings !== null && data.surroundings?.features?.length) bboxPoly = union(bboxPoly, bboxPolygon(calcBbox(data.surroundings))); - if (data?.trees !== null) + if (data?.trees !== null && data.trees?.features?.length) bboxPoly = union(bboxPoly, bboxPolygon(calcBbox(data.trees))); cameraOptions.current = mapbox.cameraForBounds(calcBbox(bboxPoly), {