카카오 지오코딩 호출을 try/catch로 감싼다.

- 외부(카카오) SDK 예외가 미처리 예외로 전파되어 콘솔 오염·
  DevTools "예외에서 일시중지"로 화면이 멈추는 것을 방지
- geocodeChain 호출 및 마커 생성 콜백을 방어적으로 보호

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
taekyoungc
2026-06-08 12:53:02 +09:00
parent 6b1c118651
commit 600a79788e

View File

@@ -115,19 +115,21 @@ $mapId = 'mainKakaoMap';
(function next(i) { (function next(i) {
if (i >= tries.length) { cb(null); return; } if (i >= tries.length) { cb(null); return; }
var mode = tries[i][0], q = tries[i][1]; var mode = tries[i][0], q = tries[i][1];
if (mode === 'addr') { try {
geocoder.addressSearch(q, function (result, status) { if (mode === 'addr') {
if (status === kakao.maps.services.Status.OK && result && result[0]) { geocoder.addressSearch(q, function (result, status) {
cb(new kakao.maps.LatLng(result[0].y, result[0].x)); if (status === kakao.maps.services.Status.OK && result && result[0]) {
} else { next(i + 1); } cb(new kakao.maps.LatLng(result[0].y, result[0].x));
}); } else { next(i + 1); }
} else { });
places.keywordSearch(q, function (data, status) { } else {
if (status === kakao.maps.services.Status.OK && data && data[0]) { places.keywordSearch(q, function (data, status) {
cb(new kakao.maps.LatLng(data[0].y, data[0].x)); if (status === kakao.maps.services.Status.OK && data && data[0]) {
} else { next(i + 1); } cb(new kakao.maps.LatLng(data[0].y, data[0].x));
}); } else { next(i + 1); }
} });
}
} catch (e) { cb(null); }
})(0); })(0);
} }
@@ -165,15 +167,17 @@ $mapId = 'mainKakaoMap';
SHOPS.forEach(function (shop, idx) { SHOPS.forEach(function (shop, idx) {
geocodeChain(shop, function (pos) { geocodeChain(shop, function (pos) {
pending--; pending--;
if (pos) { try {
var marker = new kakao.maps.Marker({ position: pos, map: map }); if (pos) {
markers[idx] = marker; var marker = new kakao.maps.Marker({ position: pos, map: map });
positions[idx] = pos; markers[idx] = marker;
bounds.extend(pos); placed++; positions[idx] = pos;
kakao.maps.event.addListener(marker, 'click', function () { openInfo(idx); }); bounds.extend(pos); placed++;
var dot = document.querySelector('.shop-item[data-idx="' + idx + '"] .shop-dot'); kakao.maps.event.addListener(marker, 'click', function () { openInfo(idx); });
if (dot) { dot.style.background = '#243a5e'; } var dot = document.querySelector('.shop-item[data-idx="' + idx + '"] .shop-dot');
} if (dot) { dot.style.background = '#243a5e'; }
}
} catch (e) {}
if (pending === 0) done(); if (pending === 0) done();
}); });
}); });