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
42 changes: 0 additions & 42 deletions src/components/map/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,47 +185,6 @@ function MapBootstrapSync({
return null;
}

/** 가로 월드 래핑(지도 타일 무한 복제) 시 마지막 유효 중심으로 되돌림 */
function MapPreventHorizontalWrap() {
const map = useMap();
const lastValidCenterRef = useRef<google.maps.LatLngLiteral | null>(null);

useEffect(() => {
if (!map) return;

const listener = map.addListener("center_changed", () => {
const bounds = map.getBounds();
if (!bounds) return;

const ne = bounds.getNorthEast();
const sw = bounds.getSouthWest();
if (ne.lng() > sw.lng()) {
const c = map.getCenter();
if (c) {
lastValidCenterRef.current = { lat: c.lat(), lng: c.lng() };
}
return;
}

const last = lastValidCenterRef.current;
if (last) {
panToWithinWorld(map, last);
}
});

const c = map.getCenter();
if (c) {
lastValidCenterRef.current = { lat: c.lat(), lng: c.lng() };
}

return () => {
google.maps.event.removeListener(listener);
};
}, [map]);

return null;
}

// ─── 방 destination 변경 시 지도 동기화(설정 수정 등)·캐시 갱신 ───────────────

function DestinationPanController({
Expand Down Expand Up @@ -590,7 +549,6 @@ export default function TripMap({
zoom={bootstrap.zoom}
roomId={currentRoomId}
/>
<MapPreventHorizontalWrap />
<SelectedPlaceController />
{!routeView && isMobileDevice ? <MobileSearchSelection /> : null}
{/* 웹 일정에서 고른 장소로 이동 — 모바일(일반 지도·경로 보기)은 쓰지 않는다 */}
Expand Down
5 changes: 5 additions & 0 deletions src/lib/maps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ export const MAP_WORLD_LAT_LNG_BOUNDS: google.maps.LatLngBoundsLiteral = {
east: 179.999,
};

/**
* 가로 래핑도 이 restriction만으로 막는다. `center_changed`에서 bounds를 보고 되돌리지 않는다 —
* 휠·트랙패드 확대는 `setCenter` 뒤에 `setZoom`이 와서 그 사이 bounds(새 중심·이전 줌)가 날짜변경선을 넘은 것처럼 보이고,
* 이때 되돌리면 확대가 끊겨 줌 값만 바뀌고 화면은 멈춘다.
*/
export const MAP_PAN_RESTRICTION: google.maps.MapRestriction = {
latLngBounds: MAP_WORLD_LAT_LNG_BOUNDS,
strictBounds: true,
Expand Down
Loading