Skip to content

[chore/#316] 지도뷰 진입 시 카메라 이동 애니메이션 삭제#323

Merged
SeungWon1125 merged 4 commits intodevelopfrom
chore/#316-map-initial-coordinate
Nov 6, 2025
Merged

[chore/#316] 지도뷰 진입 시 카메라 이동 애니메이션 삭제#323
SeungWon1125 merged 4 commits intodevelopfrom
chore/#316-map-initial-coordinate

Conversation

@SeungWon1125
Copy link
Copy Markdown
Collaborator

@SeungWon1125 SeungWon1125 commented Nov 6, 2025

📄 작업 내용

  • 지도가 있는 뷰(장소 상세, 코스 상세)에 진입 시 초기 좌표에서 카메라가 시작되던 부분을 수정했어요
    (원래는 저 멀리서부터 날아왔음)
구현 내용 장소 상세 코스 상세
iPhone 13 mini

💻 주요 코드 설명

장소 상세 & 코스 상세

private func configureCameraWithCalculatedZoom(_ mapView: NMFMapView,
    let centerCoordinate = calculateCenterCoordinate()
    let calculatedZoomLevel = calculateOptimalZoomLevel()
    
    DispatchQueue.main.async {
        let cameraUpdate = NMFCameraUpdate(scrollTo: centerCoordinate, zoomTo:
        
        if coordinator.didInitialMove == false {
            cameraUpdate.animation = .none
            coordinator.didInitialMove = true
        } else {
            cameraUpdate.animation = .fly
        }
        
        mapView.moveCamera(cameraUpdate)
    }
}

첫 애니메이션을 끄는 방식으로 구현했습니다.
첫 애니메이션이 (초기값) -> (특정 코스들의 중심 좌표)로 이동이기 때문에 해당 애니메이션을 끄는 방식으로 수정했어요

했던 고민

장소 상세나, 코스 상세를 fetch하기 전에 지도뷰가 그려지고, fetch된 데이터에서 좌표값을 기반으로 지도에 카메라나 마커를 표시하기 때문에
초기값 -> 우리가 보고싶은 좌표로 이동이 생기게 됩니다.
(원래의 문제는 기본값으로 .fly 애니메이션을 적용해서 이 초기값에서 이동하는 과정에도 애니메이션이 생겼던 것입니닷)

처음에는 fetch될 때까지 지도를 그리지 말고 데이터를 받음과 동시에 지도를 초기화 할까 고민해 봤지만,
데이터가 느리게 받아와지는 경우 지도가 아에 보이지 않는 상황이 발생해 이 부분에서 오히려 UX를 해친다 생각하여
지도는 보이지만, 데이터가 받아와졌을 때 애니메이션 없이 빠르게 카메라를 이동시키게 했어요

🔗 연결된 이슈

@SeungWon1125 SeungWon1125 requested a review from a team November 6, 2025 09:51
@SeungWon1125 SeungWon1125 self-assigned this Nov 6, 2025
@SeungWon1125 SeungWon1125 added 🦒 seungwon 승원이가함! ✂️ fix 버그나 오류 해결 시 사용 labels Nov 6, 2025
@SeungWon1125 SeungWon1125 linked an issue Nov 6, 2025 that may be closed by this pull request
1 task
@SeungWon1125 SeungWon1125 added the 📎 chore 별로 중요한 수정이 아닐 시 사용 label Nov 6, 2025
Comment on lines +95 to +103
func configureCamera(_ mapView: NMFMapView, coordinator: Coordinator) {
DispatchQueue.main.async {
let cameraUpdate = NMFCameraUpdate(
scrollTo: NMGLatLng(lat: latitude, lng: longitude),
zoomTo: zoomLevel
)
cameraUpdate.animation = .fly

if coordinator.currentLatitude == 0.0 && coordinator.currentLongitude == 0.0 {
cameraUpdate.animation = .none
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coordinator를 인자로 받는 형태로 변경한 건 좋아여

근디 (0.0, 0.0)으로 초기 여부를 판단하는 것 같은데, didInitialMove Bool 플래그를 쓰면 안되는건가요??
둘이 모가 다른거조

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아놔

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

방금 고쳤는데, CourseDetailMapView는 데이터 배열이 비어있을 때 guard문 처리를 해서 중복 호출을 방지했더라고요 (과거의 제가) 그래서 플래그 형식으로 구현이 가능했던 것이고, PlaceDetailMapView에서는 그런 처리를 하지 않았었기 때문에(과거의 제가) 중복으로 불려서 플래그가 안 먹혔네요

결론

PlaceDetailMapViewUpdateUIView()가 불릴 때 처음 (0.0, 0.0)으로 초기화 될 때 UI가 업데이트되는 것을 guard로 막고,
이후 (0.0, 0.0) -> 장소 좌표로 이동할 때는 플래그값으로 애니메이션을 .none으로 (CourseDetailMapView방식과 동일) 하도록 수정했어요~!

@dudwntjs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

역시 성공하실 줄 알고 잇엇더요 굿

@SeungWon1125 SeungWon1125 requested review from a team and dudwntjs November 6, 2025 15:02
@SeungWon1125 SeungWon1125 merged commit 9d28980 into develop Nov 6, 2025
@SeungWon1125 SeungWon1125 deleted the chore/#316-map-initial-coordinate branch November 6, 2025 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📎 chore 별로 중요한 수정이 아닐 시 사용 ✂️ fix 버그나 오류 해결 시 사용 🦒 seungwon 승원이가함!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[chore] 장소 상세, 코스 상세 초기 좌표 설정

2 participants