"use client"; import { useEffect } from "react"; import { MapContainer, TileLayer, Marker, Popup, useMap } from "react-leaflet"; import L from "leaflet"; import type { NodeRecord, CallRecord } from "@/lib/types"; import "leaflet/dist/leaflet.css"; // Fix Leaflet default icon paths broken by webpack delete (L.Icon.Default.prototype as unknown as Record)._getIconUrl; L.Icon.Default.mergeOptions({ iconRetinaUrl: "https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon-2x.png", iconUrl: "https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png", shadowUrl: "https://unpkg.com/leaflet@1.9.4/dist/images/marker-shadow.png", }); const nodeIcon = (status: string) => L.divIcon({ className: "", html: `
`, iconSize: [14, 14], iconAnchor: [7, 7], }); interface Props { nodes: NodeRecord[]; activeCalls: CallRecord[]; } export default function MapView({ nodes, activeCalls }: Props) { const activeByNode = Object.fromEntries( activeCalls.map((c) => [c.node_id, c]) ); const center: [number, number] = nodes.length > 0 ? [nodes[0].lat, nodes[0].lon] : [39.5, -98.35]; return ( 0 ? 10 : 4} className="w-full h-full rounded-lg" style={{ background: "#111827" }} > {nodes.map((node) => (

{node.name}

{node.node_id}

{node.status}

{activeByNode[node.node_id] && (

● TG {activeByNode[node.node_id].talkgroup_id ?? "—"}{" "} {activeByNode[node.node_id].talkgroup_name}

)}
))}
); }