File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff 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` ) ;
You can’t perform that action at this time.
0 commit comments