fix: 업무현황 지도 첫 진입 시 판매소 미표시 수정 (ResizeObserver relayout)

워크스페이스 탭(iframe) 안에서 컨테이너 크기 확정 전 지도가 초기화돼 반만/일본으로 보이던 문제.
크기 변화마다 relayout+setBounds 재적용.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
taekyoungc
2026-06-16 15:39:02 +09:00
parent c3e8ebfe6d
commit 4e681d08cc

View File

@@ -158,9 +158,32 @@ $mapId = 'mainKakaoMap';
var bounds = new kakao.maps.LatLngBounds(); var bounds = new kakao.maps.LatLngBounds();
var placed = 0, pending = SHOPS.length; var placed = 0, pending = SHOPS.length;
// 컨테이너 크기에 맞춰 지도를 다시 그리고 영역을 재설정한다.
function refit() {
if (!mapRef) return;
mapRef.relayout();
if (placed > 0) { mapRef.setBounds(bounds); }
else { mapRef.setCenter(new kakao.maps.LatLng(DEFAULT_CENTER.lat, DEFAULT_CENTER.lng)); }
}
var refitScheduled = false;
function scheduleRefit() {
if (refitScheduled) return;
refitScheduled = true;
(window.requestAnimationFrame || window.setTimeout)(function () { refitScheduled = false; refit(); });
}
// 탭(iframe) 안에서 컨테이너 크기가 늦게 확정되거나 바뀌면(표시 전환·창 크기 변경 등)
// 지도가 반만 그려지거나 엉뚱한 위치(일본 등)로 보이므로, 크기 변화 때마다 다시 맞춘다.
try {
if (typeof ResizeObserver !== 'undefined') { new ResizeObserver(scheduleRefit).observe(el); }
} catch (e) {}
window.addEventListener('resize', scheduleRefit);
window.addEventListener('pageshow', function () { setTimeout(refit, 50); });
function done() { function done() {
if (placed > 0) map.setBounds(bounds); refit();
setTimeout(function () { map.relayout(); if (placed > 0) map.setBounds(bounds); }, 150); setTimeout(refit, 150);
setTimeout(refit, 600);
} }
if (pending === 0) { done(); return; } if (pending === 0) { done(); return; }