카카오 지오코딩 호출을 try/catch로 감싼다.
- 외부(카카오) SDK 예외가 미처리 예외로 전파되어 콘솔 오염· DevTools "예외에서 일시중지"로 화면이 멈추는 것을 방지 - geocodeChain 호출 및 마커 생성 콜백을 방어적으로 보호 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -115,6 +115,7 @@ $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];
|
||||||
|
try {
|
||||||
if (mode === 'addr') {
|
if (mode === 'addr') {
|
||||||
geocoder.addressSearch(q, function (result, status) {
|
geocoder.addressSearch(q, function (result, status) {
|
||||||
if (status === kakao.maps.services.Status.OK && result && result[0]) {
|
if (status === kakao.maps.services.Status.OK && result && result[0]) {
|
||||||
@@ -128,6 +129,7 @@ $mapId = 'mainKakaoMap';
|
|||||||
} else { next(i + 1); }
|
} else { next(i + 1); }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} catch (e) { cb(null); }
|
||||||
})(0);
|
})(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,6 +167,7 @@ $mapId = 'mainKakaoMap';
|
|||||||
SHOPS.forEach(function (shop, idx) {
|
SHOPS.forEach(function (shop, idx) {
|
||||||
geocodeChain(shop, function (pos) {
|
geocodeChain(shop, function (pos) {
|
||||||
pending--;
|
pending--;
|
||||||
|
try {
|
||||||
if (pos) {
|
if (pos) {
|
||||||
var marker = new kakao.maps.Marker({ position: pos, map: map });
|
var marker = new kakao.maps.Marker({ position: pos, map: map });
|
||||||
markers[idx] = marker;
|
markers[idx] = marker;
|
||||||
@@ -174,6 +177,7 @@ $mapId = 'mainKakaoMap';
|
|||||||
var dot = document.querySelector('.shop-item[data-idx="' + idx + '"] .shop-dot');
|
var dot = document.querySelector('.shop-item[data-idx="' + idx + '"] .shop-dot');
|
||||||
if (dot) { dot.style.background = '#243a5e'; }
|
if (dot) { dot.style.background = '#243a5e'; }
|
||||||
}
|
}
|
||||||
|
} catch (e) {}
|
||||||
if (pending === 0) done();
|
if (pending === 0) done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user