diff --git a/src/api/MapDetail.js b/src/api/MapDetail.js index 503cc65..b7c2935 100644 --- a/src/api/MapDetail.js +++ b/src/api/MapDetail.js @@ -1,7 +1,7 @@ // MapDetail.js export const getPlaceDetails = async ({ placeId }) => { - const apiKey = "AIzaSyBPG58Nk2zPjucy4apqdFTrUxZl0bGpddU"; // 여기에 자신의 Google Maps API 키를 입력하세요. + const apiKey = "AIzaSyBtvVmyyvzbg4OILHqlzB8eGJcP03-lSVk"; // 여기에 자신의 Google Maps API 키를 입력하세요. const url = `https://maps.googleapis.com/maps/api/place/details/json?placeid=${placeId}&key=${apiKey}`; try { diff --git a/src/components/Map.js b/src/components/Map.js index a642c04..e3abaa7 100644 --- a/src/components/Map.js +++ b/src/components/Map.js @@ -1,7 +1,7 @@ import React, { useState, useEffect } from "react"; import { GoogleMap, LoadScript, Marker } from "@react-google-maps/api"; -const containerStyle = { +const containerStyleDefault = { position: "absolute", top: 0, left: 0, @@ -11,25 +11,26 @@ const containerStyle = { }; const defaultCenter = { - lat: 36.32800, + lat: 36.328, lng: 128.02379, }; -const Map = ({ location, recommendations, onPinClick, zoomLevel = 7.2, containerStyle }) => { - const [map, setMap] = useState(null); +const Map = ({ + location, + recommendations, + onPinClick, + zoomLevel = 7.2, + containerStyle = containerStyleDefault, +}) => { const [markers, setMarkers] = useState([]); - const onLoad = (map) => { - setMap(map); - }; - useEffect(() => { let newMarkers = []; if (recommendations && recommendations.length > 0) { newMarkers = recommendations.map((place, index) => ({ position: { lat: place.lat, lng: place.lng }, label: `${index + 1}`, - name: place.name + name: place.name, })); } else if (location && location.lat !== null && location.lng !== null) { newMarkers = [{ position: location, label: "1" }]; @@ -37,16 +38,19 @@ const Map = ({ location, recommendations, onPinClick, zoomLevel = 7.2, container setMarkers(newMarkers); }, [location, recommendations]); - const handleMarkerClick = (marker) => { - onPinClick(marker.name); - }; - return (
- + console.log("Google Maps API loaded successfully")} + loadingElement={
} + libraries={["places"]} + region="KR" + language="ko" + id="script-loader" + > @@ -55,7 +59,7 @@ const Map = ({ location, recommendations, onPinClick, zoomLevel = 7.2, container key={index} position={marker.position} label={marker.label} - onClick={() => handleMarkerClick(marker)} // Pass marker to handleMarkerClick + onClick={() => onPinClick(marker.name)} /> ))} diff --git a/src/components/OAuthCallback.js b/src/components/OAuthCallback.js index 5e2ebc3..f9e282e 100644 --- a/src/components/OAuthCallback.js +++ b/src/components/OAuthCallback.js @@ -13,12 +13,15 @@ const OAuthCallback = () => { const fetchUserProfile = async () => { if (accessToken) { try { - const response = await fetch("http://dev.enble.site/me/info", { - method: "GET", - headers: { - Authorization: `Bearer ${accessToken}`, - }, - }); + const response = await fetch( + "https://travel-compass.persi0815.site", + { + method: "GET", + headers: { + Authorization: `Bearer ${accessToken}`, + }, + } + ); const data = await response.json(); if (data.isSuccess) { diff --git a/src/components/Search.js b/src/components/Search.js index c280e6a..4648f82 100644 --- a/src/components/Search.js +++ b/src/components/Search.js @@ -3,7 +3,6 @@ import styles from "../styles/searchplace/search.module.css"; import { Search } from "../styles/styles.jsx"; import Moving from "../assets/images/Place/Vector.svg"; - const SearchComponent = ({ onSearch }) => { const [searchQuery, setSearchQuery] = useState(""); const [showSuggestions, setShowSuggestions] = useState(false); @@ -40,18 +39,18 @@ const SearchComponent = ({ onSearch }) => { const handleSearch = async (event) => { event.preventDefault(); - + try { // Geocoding API 호출을 위한 URL - const geocodingApiUrl = `https://maps.googleapis.com/maps/api/geocode/json?address=${searchQuery}&key=AIzaSyBPG58Nk2zPjucy4apqdFTrUxZl0bGpddU`; - + const geocodingApiUrl = `https://maps.googleapis.com/maps/api/geocode/json?address=${searchQuery}&key=AIzaSyBtvVmyyvzbg4OILHqlzB8eGJcP03-lSVk`; + // Geocoding API 호출 const response = await fetch(geocodingApiUrl); const data = await response.json(); - + // 검색어로부터 위치 좌표 가져오기 const location = data.results[0]?.geometry?.location; - + if (location) { // 검색된 위치와 검색어를 부모 컴포넌트로 전달하여 지도를 업데이트 onSearch(location, searchQuery); @@ -87,8 +86,8 @@ const SearchComponent = ({ onSearch }) => { border: "none", borderRadius: "5px", outline: "none", - paddingLeft: "17px", // 텍스트 왼쪽 여백 조절 - marginRight: "-45px", // 버튼과 간격 조절 + paddingLeft: "17px", + marginRight: "-45px", }} />