gmaps API v3 very slow loading on IE [duplicate]

2019-08-06 13:51发布

问题:

This question already has an answer here:

  • Google Maps JSv3 Freezes for a few seconds every 30 seconds 3 answers

this is my first post, so I hope I'm in the right place. I've created a local html page with a map using google maps API v3.0. It works fine on Chrome and Firefox but not on IE. When I try to open the map, the browser remains stuck on a white page loding the maps for more than 30/40 seconds. Once the maps appears everything is ok.

The same happens with the example provided by google (https://developers.google.com/maps/documentation/javascript/examples/map-simple)

I've searched on google for hours but I didn't find any solution. Any help would be very appreciate.

回答1:

I think it might be because of the style sheet.

According to this website,

IE needs to know the size of the map ensure that it has been set

It seems like IE might not try to determine until the page is fully loaded, which sometime takes a long time. That being said, adding the width:100%; in the css style sheet should help. At least it works for me.

I hosted a simple map with width:100%; here.