Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check Connectivity to Google Maps API (China Great Firewall)

I'm currently working on a platform that will be launched all over the world and I am working in Shanghai China and as you might know there is a very big Firewall policy here.

The site contains a custom map view created with the Google Maps API this is because Google allows a lot of nice features to change the look and feel of the map.

But now I'm running into a problem where if a user wants to access the site without VPN the whole page where the map is located slows down,crashes and breaks my login procedure.

Here are the errors showing in the Console View:

GET https://maps.googleapis.com/maps/api/js?key=1010101010101&sensor=true net::ERR_CONNECTION_TIMED_OUT

Uncaught ReferenceError: google is not defined

I want to know if there is a way to check if I have a connection to the Google Maps API before executing the code?

Cheers,

Koen

like image 526
Koen H Avatar asked Feb 26 '15 02:02

Koen H


1 Answers

Checking if the API is loaded, as Keith links above, is a good way to see if the loading has had any trouble.

To minimize problems loading the API in China the Maps API FAQ recommends loading the API from http://maps.google.cn/maps/api/js and not using https.

like image 121
bamnet Avatar answered Sep 30 '22 06:09

bamnet