diff --git a/app/components/MapView.client.vue b/app/components/MapView.client.vue index c342a75..4dd1418 100644 --- a/app/components/MapView.client.vue +++ b/app/components/MapView.client.vue @@ -241,13 +241,15 @@ function renderRoute(route: RouteResult, selected: number) { const pts: [number, number][] = [] if (it) { const nodes = [it.legs[0]?.fromCoords, ...it.legs.map((l) => l.toCoords)].filter(Boolean) as [number, number][] - nodes.forEach((c, i) => { + // A loop and not `forEach`: inside a callback TypeScript widens `map` back to nullable, + // the guard at the top of the function no longer covering it. + for (const [i, c] of nodes.entries()) { pts.push(c) if (i > 0 && i < nodes.length - 1) { const el = dot('#14b8b0', 14) markers.set(`__via_${i}__`, new maplibregl.Marker({ element: el }).setLngLat([c[1], c[0]]).addTo(map)) } - }) + } if (nodes.length > 1) { map.addSource('route-line', { type: 'geojson', diff --git a/app/components/RoutePanel.vue b/app/components/RoutePanel.vue index 7aa3898..65c0df7 100644 --- a/app/components/RoutePanel.vue +++ b/app/components/RoutePanel.vue @@ -1,7 +1,7 @@