'use client'; import { AdvancedMarker } from '@vis.gl/react-google-maps'; import { useCallback, useState } from 'react'; const FUEL_TYPE_COLORS: Record = { Coal: '#4A4A4A', 'Natural Gas': '#F59E0B', Nuclear: '#8B5CF6', Hydroelectric: '#3B82F6', Wind: '#06B6D4', Solar: '#FBBF24', Petroleum: '#78716C', Biomass: '#22C55E', Geothermal: '#EF4444', }; function getFuelColor(fuelType: string): string { return FUEL_TYPE_COLORS[fuelType] ?? '#9CA3AF'; } function getDiamondSize(capacityMw: number): number { if (capacityMw >= 2000) return 20; if (capacityMw >= 1000) return 16; if (capacityMw >= 500) return 13; if (capacityMw >= 200) return 10; return 8; } export interface PowerPlantMarkerData { id: string; plant_code: number; name: string; operator: string; capacity_mw: number; fuel_type: string; state: string; lat: number; lng: number; } interface PowerPlantMarkerProps { plant: PowerPlantMarkerData; } export function PowerPlantMarker({ plant }: PowerPlantMarkerProps) { const [hovered, setHovered] = useState(false); const size = getDiamondSize(plant.capacity_mw); const color = getFuelColor(plant.fuel_type); const handleMouseEnter = useCallback(() => setHovered(true), []); const handleMouseLeave = useCallback(() => setHovered(false), []); return (
{hovered && (
{plant.name}
{plant.fuel_type} · {plant.capacity_mw} MW
)}
); } export { FUEL_TYPE_COLORS };