简体   繁体   中英

google maps not loading correclty when first viewing website

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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM