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.
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.