Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/features/map/components/MapViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export const MapViewer = forwardRef<MapViewerHandle, MapViewerProps>(function Ma
onCurrentLocationError,
centerOnFirstLocation,
isTrackingEnabled: !isLocationTrackingDisabled,
flyTo,
});

useImperativeHandle(
Expand Down
10 changes: 5 additions & 5 deletions src/features/map/hooks/useCurrentLocationMarker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ type UseCurrentLocationMarkerParams = {
onCurrentLocationError?: (message: string) => void;
centerOnFirstLocation?: boolean;
isTrackingEnabled?: boolean;
/** 재중심 이동 시 순간이동 대신 부드럽게 pan+zoom하기 위해 useGoogleMap의 flyTo를 그대로 재사용한다. */
flyTo: (position: MapCoordinate, targetZoom: number, onArrive?: () => void) => void;
};

/** 현재 위치 마커(방향 쐐기 포함)를 실시간으로 추적/렌더링하고, 재중심 이동 함수를 제공한다. */
Expand All @@ -43,6 +45,7 @@ export function useCurrentLocationMarker({
onCurrentLocationError,
centerOnFirstLocation = true,
isTrackingEnabled = true,
flyTo,
}: UseCurrentLocationMarkerParams) {
const overlayRef = useRef<CurrentLocationOverlayHandle | null>(null);
const positionRef = useRef<MapCoordinate | null>(null);
Expand Down Expand Up @@ -240,12 +243,9 @@ export function useCurrentLocationMarker({
const position = positionRef.current;
if (!map || !position) return false;

// 축소된 상태에서 panTo부터 하면 restriction이 넓은 뷰포트 기준으로
// 좌표를 다시 clamp해버릴 수 있어, 줌을 먼저 좁힌 뒤에 이동한다.
map.setZoom(RECENTER_ZOOM);
map.panTo(position);
flyTo(position, RECENTER_ZOOM);
return true;
}, [enableCompassIfNeeded, mapInstanceRef]);
}, [enableCompassIfNeeded, flyTo, mapInstanceRef]);

return { recenterToCurrentLocation };
}
6 changes: 3 additions & 3 deletions src/pages/MapPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -598,9 +598,9 @@ const MapPage: React.FC<MapPageProps> = ({
hasReliableUserLocation={Boolean(currentLocation ?? selectedMapPlace.selectionLocation)}
detailLocationError={currentLocationError}
onPinClick={(pin) => {
// 뒤로가기 시 같은 바텀시트로 복귀해야 하므로 선택 상태를 지우지 않는다.
const latitude = currentLocation?.lat ?? selectedMapPlace.selectionLocation?.latitude;
const longitude = currentLocation?.lng ?? selectedMapPlace.selectionLocation?.longitude;
onClearMapPlace?.();
navigate(`/app/pins/${pin.placeTrackId}`, {
state: {
...(latitude != null && longitude != null
Expand All @@ -624,9 +624,9 @@ const MapPage: React.FC<MapPageProps> = ({
});
}}
onFocusedTrackClick={(placeTrackId) => {
// 뒤로가기 시 같은 바텀시트로 복귀해야 하므로 선택 상태를 지우지 않는다.
const latitude = currentLocation?.lat ?? selectedMapPlace.selectionLocation?.latitude;
const longitude = currentLocation?.lng ?? selectedMapPlace.selectionLocation?.longitude;
onClearMapPlace?.();
navigate(`/app/pins/${placeTrackId}`, {
state: {
...(latitude != null && longitude != null
Expand Down Expand Up @@ -673,7 +673,7 @@ const MapPage: React.FC<MapPageProps> = ({
hasReliableUserLocation={Boolean(currentLocation)}
detailLocationError={currentLocationError}
onPinClick={(pin) => {
onSelectMapPinChange(null);
// 뒤로가기 시 같은 바텀시트로 복귀해야 하므로 선택 상태를 지우지 않는다.
navigate(`/app/pins/${pin.placeTrackId}`, {
state:
currentLocation != null
Expand Down
Loading