import { useEffect, useState } from 'react' import { MapContainer, TileLayer, Marker, Popup } from 'react-leaflet' import { Icon } from 'leaflet' import { Attraction } from '../types' import 'leaflet/dist/leaflet.css' interface MapProps { attractions: Attraction[] } // 커스텀 마커 아이콘 설정 const attractionIcon = new Icon({ iconUrl: 'https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-red.png', shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png', iconSize: [25, 41], iconAnchor: [12, 41], popupAnchor: [1, -34], shadowSize: [41, 41] }) const Map = ({ attractions }: MapProps) => { const [isMounted, setIsMounted] = useState(false) // 클라이언트 사이드에서만 렌더링 (SSR 에러 방지) useEffect(() => { setIsMounted(true) }, []) // 구마모토 중심 좌표 const kumamotoCenter: [number, number] = [32.8031, 130.7079] // 타일 서버 URL (Docker 컨테이너 또는 기본 OSM) const tilesUrl = import.meta.env.VITE_MAP_TILES_URL || 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png' const isCustomTiles = !!import.meta.env.VITE_MAP_TILES_URL // 서버 사이드에서는 로딩 화면 표시 if (!isMounted) { return (
지도를 불러오는 중...
{attraction.description}
📍 {attraction.location}
{attraction.website && ( 웹사이트 방문 )}