Check connectivity with the Google Maps API (Chinese Firewall)

I am currently working on a platform that will be launched worldwide, and I work in Shanghai, China, and, as you know, there is a very big firewall policy here.

The site contains a custom map view created using the Google Maps API, because Google allows many nice features to change the look of the map.

But now I have a problem: if the user wants to access the site without a VPN, the entire page on which the card is located slows down, crashing and interrupting my login procedure.

The following are errors displayed 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?

Greetings

Koen

+6
source share
1 answer

Checking if the API is loaded, like the Keith links above, is a good way to see if the download has any problems.

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

+1
source

Source: https://habr.com/ru/post/983012/


All Articles