diff --git a/src/pages/Map/index.tsx b/src/pages/Map/index.tsx index c8050b61..ab75651e 100644 --- a/src/pages/Map/index.tsx +++ b/src/pages/Map/index.tsx @@ -91,13 +91,26 @@ const generateNeighborLines = ( }; }; const generateDirectLines = (nodes: Protobuf.Mesh.NodeInfo[]) => { - const features = []; + const selfNode = nodes.find((n) => n.isFavorite); + const features: { + type: string; + geometry: { + type: string; + coordinates: number[][]; + }; + properties: { + color: string; + }; + }[] = []; + + if (!selfNode || !selfNode.position) + return { type: "FeatureCollection", features }; + for (const node of nodes) { if (!node.position) continue; if (node.hopsAway > 0) continue; if (Date.now() / 1000 - node.lastHeard > DIRECT_NODE_TIMEOUT) continue; const start = convertToLatLng(node.position); - const selfNode = nodes.find((n) => n.isFavorite); const end = convertToLatLng(selfNode.position); features.push({ type: "Feature",