Thursday, March 21, 2013

Google Maps stuck at loading


Problem:
After adding the Google Maps API v3 to a website, the map page, in Firefox, displays a strange behavior.
When the request comes from another page, most times, the map page keeps loading the Google Maps API ("retrieving data from maps.googleapis.com") but it never actually ends.
Follow-up scripts end up never being loaded.
If we stop the page load and refresh it (F5 or CTRL+F5), the page loads correctly.

Solution:
There are lots of posts already with people trying to figure this out.
Some are recomending changing the google script call to asynchronous:

http://stackoverflow.com/questions/14233350/infinite-load-on-firefox-transferring-data-from-maps-googleapis-com
https://developers.google.com/maps/documentation/javascript/tutorial#Loading_the_Maps_API

However, for me, I just needed to move from

$(document).ready(function () {
                    initializeMap();
                });

to

$(window).load(function () {
                    initializeMap();
                });

http://stackoverflow.com/questions/13940500/google-maps-api-keeps-loading-on-firefox


No comments:

Post a Comment