Google지도를 비동기 적으로로드하려고하는데 작동하지만지도가 두 번로드됩니다. "box.onload = initialize;
"을 제거하면 문제가 해결되지만 infobox가 표시되지 않습니다 ... 내 코드를 수정하여지도를 한 번만로드하고 infobox를 표시하는 방법은 무엇입니까?Google지도를 비동기 적으로로드 중
function loadScript() {
var map = document.createElement('script');
map.type = 'text/javascript';
map.src = 'https://maps.googleapis.com/maps/api/js?key=key_goes_here&sensor=false&callback=initialize';
document.body.appendChild(map);
map.onload = function() {
var box = document.createElement('script');
box.type = 'text/javascript';
box.src = 'https://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/src/infobox_packed.js';
document.body.appendChild(box);
box.onload = initialize;
};
}
window.onload = loadScript;
문제는 당신이'호출 끝날거야처럼 나에게 보이는 것입니다 모두 작업 :( – duncan
에서 콜백을 제거 initialize' 두 번. 아마도 box.onload가 다른 함수를 호출해야합니다. –
을에서지도를 정지하여 map.src – duncan