"use client"; import { MapContainer, TileLayer, Marker, Popup } from 'react-leaflet'; import 'leaflet/dist/leaflet.css'; import L from 'leaflet'; import { useEffect } from 'react'; import { renderToStaticMarkup } from 'react-dom/server'; import { Coffee } from 'lucide-react'; interface CoffeeShop { id: number; name: string; description: string; lat: number; lng: number; } interface MapProps { shops: CoffeeShop[]; onShopSelect: (shop: CoffeeShop) => void; } const Map = ({ shops, onShopSelect }: MapProps) => { useEffect(() => { // No longer need default icon fix as we are using custom icons }, []); const createCustomIcon = () => { const iconMarkup = renderToStaticMarkup(
); return L.divIcon({ html: iconMarkup, className: 'custom-marker', // Add a class for potential extra styling iconSize: [32, 32], iconAnchor: [16, 32], // Anchor at bottom center popupAnchor: [0, -32], }); }; const customIcon = createCustomIcon(); return ( {shops.map((shop) => ( onShopSelect(shop), }} /> ))} ); }; export default Map;