Skip to content

Commit

Permalink
feat(#75) : 지도보기 선택 시 위치 고정
Browse files Browse the repository at this point in the history
  • Loading branch information
KangBoSeok-kor committed Dec 11, 2024
1 parent 2e5fdc7 commit e8dd28b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/app/place/placesearch/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const ActualPlaceSearchPage = () => {
const [userLocation, setUserLocation] = useState(null);
const [isLocationPermissionGranted, setIsLocationPermissionGranted] = useState(false);
const [showScrollToTop, setShowScrollToTop] = useState(false);
const [searchedLocation, setSearchedLocation] = useState(null);
const [buttonBottom, setButtonBottom] = useState(30);
const bottomRef = useRef(null);
const scrollableRef = useRef(null);
Expand Down Expand Up @@ -186,6 +187,7 @@ const ActualPlaceSearchPage = () => {
}));
setAllCards(mappedPlaces);
setCards(mappedPlaces);
setSearchedLocation({ lat, lng });
console.log(places);
} catch (error) {
console.error("Error fetching places:", error);
Expand Down Expand Up @@ -221,8 +223,9 @@ const ActualPlaceSearchPage = () => {
};

const handleMapView = () => {
if (userLocation) {
const { lat, lng } = userLocation;
const location = searchedLocation || userLocation;
if (location) {
const { lat, lng } = location;
router.push(`/place/placemap?lat=${lat}&lng=${lng}`);
} else {
alert("위치를 가져올 수 없습니다.");
Expand Down

0 comments on commit e8dd28b

Please sign in to comment.