"use client"; import { useRef } from "react"; import { motion } from "framer-motion"; import DottedMap from "dotted-map"; interface MapProps { dots?: Array<{ start: { lat: number; lng: number; label?: string }; end: { lat: number; lng: number; label?: string }; }>; // New prop for dynamic standalone nodes nodes?: Array<{ lat: number; lng: number; label?: string; color?: string }>; lineColor?: string; } export default function WorldMap({ dots = [], nodes = [], lineColor = "#06b6d4", }: MapProps) { const svgRef = useRef(null); // ✅ Force dark-dotted map theme const map = new DottedMap({ height: 100, grid: "diagonal" }); const svgMap = map.getSVG({ radius: 0.22, color: "#06b6d480", shape: "circle", backgroundColor: "#111111", }); // ✅ Point projection stays the same // Projects lat/lng to the SVG's 800x400 viewBox coordinates const projectPoint = (lat: number, lng: number) => { const x = (lng + 180) * (800 / 360); const y = (90 - lat) * (400 / 180) + 45; return { x, y }; }; const createCurvedPath = (start: any, end: any) => { const midX = (start.x + end.x) / 2; // Creates an arc that bows upward by 50 units const midY = Math.min(start.y, end.y) - 50; return `M ${start.x} ${start.y} Q ${midX} ${midY} ${end.x} ${end.y}`; }; return (
world map {/* ✅ Lines + points + new standalone nodes */} {/* Glowing path gradient DEFS */} {/* ✅ DYNAMIC STANDALONE NODE DOTS (New Section) */} {nodes.map((node, i) => { const p = projectPoint(node.lat, node.lng); const dotColor = node.color || lineColor; return ( {/* Outer pulsing circle */} {/* Inner fixed circle */} ); })} {/* ✅ Animated curved travel lines (Existing Logic) */} {dots.map((dot, i) => { const startPoint = projectPoint(dot.start.lat, dot.start.lng); const endPoint = projectPoint(dot.end.lat, dot.end.lng); return ( ); })} {/* ✅ Start & end points with pulsing cyan glow (Existing Logic) */} {dots.map((dot, i) => { const s = projectPoint(dot.start.lat, dot.start.lng); const e = projectPoint(dot.end.lat, dot.end.lng); return ( {[s, e].map((p, idx) => ( ))} ); })}
); }