谷歌地图第一次查看网站时不加载correclty [英] google maps not loading correclty when first viewing website
问题描述
在查看网站时,我正在为我正在开发的一个项目开发atm - 这似乎是您第一次访问该网站时 - 位于页脚中的谷歌地图无法加载,只能加载位置图片而不是交互式地图。然而,当重新加载页面的地图工作正常:/。
我还是相当新的JS和任何帮助,将不胜感激。 b
$ b
该网站可在 http://www.kingsroad.net上查看。 au /
和主页脚页面源可以在 http://www.kingsroad.net.au/content/footerMain.php
还有kingsroad.net .au / js / general.js控制页面内容的加载。
你可以试试这样:
函数loadGoogleMap(){
var mapOptions = {
...
};
var map = new google.maps.Map(document.getElementById(map_canvas),mapOptions);
$ b setTimeout(function(){
google.maps.event.trigger(map,resize);
},3000);
}
When viewing a website I'm developing atm for a project I'm working on - it seems that the first time you visit the site - the google map located in the footer fails to load and only loads an image of the location and not the interactive map. However when reloading the page the map works fine :/.
I'm still quite new to JS and any help with this would be greatly appreciated.
The website can be seen at http://www.kingsroad.net.au/
and the main footer page source can be seen at http://www.kingsroad.net.au/content/footerMain.php
Also kingsroad.net.au/js/general.js controls the loading of content on the page.
Could you try like this:
function loadGoogleMap(){
var mapOptions = {
...
};
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
setTimeout(function() {
google.maps.event.trigger(map, "resize");
}, 3000);
}
这篇关于谷歌地图第一次查看网站时不加载correclty的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!