From af015a9c38a0faf79c5cc47c3aad344ba9265911 Mon Sep 17 00:00:00 2001 From: KangBoSeok Date: Tue, 10 Dec 2024 23:27:26 +0900 Subject: [PATCH] =?UTF-8?q?feat(#75)=20:=20=EC=8B=9C=EC=84=A4=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20URL=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/place/page.jsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/app/place/page.jsx b/src/app/place/page.jsx index 2e5dc4e..3b1c22b 100644 --- a/src/app/place/page.jsx +++ b/src/app/place/page.jsx @@ -32,8 +32,22 @@ const PlacePage = () => { } const handleImageClick = () => { - router.push(`/place/placesearch`); - } + if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition( + (position) => { + const { latitude, longitude } = position.coords; + router.push(`/place/placesearch?lat=${latitude}&lng=${longitude}`); // lat, lng 값을 URL로 전달 + }, + () => { + alert("현재 위치를 가져올 수 없습니다."); + router.push(`/place/placesearch`); // 위치를 가져오지 못했을 경우 기본 경로로 이동 + } + ); + } else { + alert("Geolocation을 지원하지 않는 브라우저입니다."); + router.push(`/place/placesearch`); // Geolocation이 없을 경우 기본 경로로 이동 + } + }; const handleImageClick2 = () => { router.push(`/recommend`);