'use client' import { useState, useRef, useEffect } from 'react' import { MapPin } from 'lucide-react' interface USMapProps { onLocationClick: (lat: number, lng: number) => void markers?: Array<{ lat: number; lng: number; label?: string }> } export default function USMap({ onLocationClick, markers = [] }: USMapProps) { const mapRef = useRef(null) const [isClient, setIsClient] = useState(false) useEffect(() => { setIsClient(true) }, []) const handleMapClick = (e: React.MouseEvent) => { if (!mapRef.current) return const rect = mapRef.current.getBoundingClientRect() const x = e.clientX - rect.left const y = e.clientY - rect.top // US map bounds (approximate) // Latitude: 24.396308 to 49.384358 // Longitude: -125.0 to -66.93457 const mapWidth = rect.width const mapHeight = rect.height // Convert pixel coordinates to lat/lng for US const lng = -125 + (x / mapWidth) * 58 // -125 to -67 const lat = 49.38 - (y / mapHeight) * 25 // 49.38 to 24.39 // Clamp to US bounds const clampedLat = Math.max(24.39, Math.min(49.38, lat)) const clampedLng = Math.max(-125, Math.min(-66.93, lng)) onLocationClick(clampedLat, clampedLng) } const projectPoint = (lat: number, lng: number, width: number, height: number) => { const x = ((lng + 125) / 58) * width const y = ((49.38 - lat) / 25) * height return { x, y } } return (
{/* US Map SVG */}
{/* Simplified US Map Outline */} {/* State boundaries (simplified) */} {/* Markers */} {isClient && markers.map((marker, i) => { const { x, y } = projectPoint( marker.lat, marker.lng, 1000, 600 ) return ( ) })} {/* Click instruction overlay */}

Click on map to report outbreak

) }