Skip to content

Commit af015a9

Browse files
feat(#75) : 시설 페이지 URL 수정
1 parent 9425d12 commit af015a9

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/app/place/page.jsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,22 @@ const PlacePage = () => {
3232
}
3333

3434
const handleImageClick = () => {
35-
router.push(`/place/placesearch`);
36-
}
35+
if (navigator.geolocation) {
36+
navigator.geolocation.getCurrentPosition(
37+
(position) => {
38+
const { latitude, longitude } = position.coords;
39+
router.push(`/place/placesearch?lat=${latitude}&lng=${longitude}`); // lat, lng 값을 URL로 전달
40+
},
41+
() => {
42+
alert("현재 위치를 가져올 수 없습니다.");
43+
router.push(`/place/placesearch`); // 위치를 가져오지 못했을 경우 기본 경로로 이동
44+
}
45+
);
46+
} else {
47+
alert("Geolocation을 지원하지 않는 브라우저입니다.");
48+
router.push(`/place/placesearch`); // Geolocation이 없을 경우 기본 경로로 이동
49+
}
50+
};
3751

3852
const handleImageClick2 = () => {
3953
router.push(`/recommend`);

0 commit comments

Comments
 (0)