Monday, June 3, 2024
32
rated 0 times [  39] [ 7]  / answers: 1 / hits: 88477  / 13 Years ago, fri, february 10, 2012, 12:00:00

How to check if Google Maps API (v3) is loaded?



I do not want to execute mapping scripts if the API did not load due to internet connectivity problems (web page is hosted locally).


More From » google-maps-api-3

 Answers
52

if (google.maps) {...} will give you a reference error if google is undefined (i.e. if the API didn't load).



Instead, use if (typeof google === 'object' && typeof google.maps === 'object') {...} to check if it loaded successfully.


[#87551] Thursday, February 9, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
willieelisham

Total Points: 201
Total Questions: 108
Total Answers: 106

Location: Zambia
Member since Sat, Oct 31, 2020
4 Years ago
willieelisham questions
Wed, Apr 14, 21, 00:00, 3 Years ago
Wed, Mar 31, 21, 00:00, 3 Years ago
Sun, Oct 11, 20, 00:00, 4 Years ago
Sat, May 9, 20, 00:00, 4 Years ago
;