0
我一直试图解决这个问题,因为昨天,但我不能让我的头在附近。我异步加载我的谷歌地图,但下面的代码引起了一个错误,这是由于信息框没有被正确加载。异步加载谷歌地图与信息框错误
我的错误是: 信息框没有定义
我的代码是:
function loadScript(callback) {
var map = document.createElement('script');
map.type = 'text/javascript';
map.src = 'https://maps.googleapis.com/maps/api/js?key=my_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 = callback;
};
}
window.onload = loadScript;
是的,我完全理解。我在这里得到了我的答案http://stackoverflow.com/questions/12148279/load-js-scripts-asynchronously-in-order-waiting-the-previous-one-is-complete,但我看到了问题,但我可以' t修复它:( – 2013-04-25 15:02:08
实际上,你想要执行初始化函数在地图加载或框加载? – duncan 2013-04-25 15:33:26
它将需要执行框加载它的工作,我认为 – 2013-04-25 15:39:41