'use client' import { useMemo } from 'react' import { MapContainer, TileLayer, CircleMarker, Tooltip } from 'react-leaflet' import 'leaflet/dist/leaflet.css' import { COUNTRIES } from '@/lib/countries' type CountryData = { countryCode: string; count: number } type LeafletMapProps = { data: CountryData[] compact?: boolean } export default function LeafletMap({ data, compact }: LeafletMapProps) { const markers = useMemo(() => { const maxCount = Math.max(...data.map((d) => d.count), 1) return data .filter((d) => d.countryCode !== 'UNKNOWN' && COUNTRIES[d.countryCode]) .map((d) => { const country = COUNTRIES[d.countryCode] const ratio = d.count / maxCount const radius = 5 + ratio * 15 return { code: d.countryCode, name: country.name, position: [country.lat, country.lng] as [number, number], count: d.count, radius, ratio, } }) }, [data]) return ( {markers.map((marker) => (
{marker.name}
{marker.count} project{marker.count !== 1 ? 's' : ''}
))}
) }