Skip to content

Commit 9cc43d1

Browse files
committed
Fix: defensive coding for route coordinates - prevent map rendering crash
1 parent 78414ce commit 9cc43d1

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/app/page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,8 @@ ${gpxPoints}
548548

549549
const getDisplayRoutes = () => {
550550
if (suggestedRoute) return [];
551-
return filteredRoutes;
551+
// Filter out routes with invalid/empty coordinates to prevent map rendering crash
552+
return filteredRoutes.filter(r => r.coordinates && r.coordinates.length > 0 && Array.isArray(r.coordinates[0]));
552553
};
553554

554555
const handleAuth = async (e: React.FormEvent) => {
@@ -1037,7 +1038,7 @@ ${gpxPoints}
10371038
)}
10381039

10391040
<div className={`flex-1 h-[50vh] md:h-auto ${darkMode ? 'bg-zinc-900' : 'bg-gray-200'} border ${darkMode ? 'border-zinc-800' : 'border-gray-300'} rounded-2xl overflow-hidden`}>
1040-
{routes.length > 0 || suggestedRoute ? (
1041+
{routes.length > 0 || (suggestedRoute && suggestedRoute.coordinates?.length > 0) ? (
10411042
<MapWithNoSSR
10421043
routes={suggestedRoute ? [] : getDisplayRoutes()}
10431044
selectedRoute={selectedRoute}

0 commit comments

Comments
 (0)