Update 2015-01-05:
As Dan pointed out in the comments, Google has instructions for using the Maps API from China: https://developers.google.com/maps/faq#china_ws_access
I had that tested and it worked! Thanks Dan!
Update 2014-11-05:
Since about September 2014, *.google.com is completely almost completely blocked in China. This work around doesn’t apply anymore š. See update above.
Original Article:
The problem
Recently I was working on Cornerstone882 website. I had the following problem: for clients located in China, Google Maps JavaScript API failed to load very often.
Moreover, the API not loading would freeze the Slideshow before its initialization, not really acceptable!
The solution
In theĀ Google Maps JavaScript API v3 tutorial, the sample code goes like:
<!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> html { height: 100% } body { height: 100%; margin: 0; padding: 0 } #map-canvas { height: 100% } </style> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=API_KEY&sensor=SET_TO_TRUE_OR_FALSE"> </script> <script type="text/javascript"> function initialize() { var mapOptions = { center: new google.maps.LatLng(-34.397, 150.644), zoom: 8, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions); } google.maps.event.addDomListener(window, 'load', initialize); </script> </head> <body> <div id="map-canvas"/> </body> </html>
Just remove the SSL protocol to download the library using HTTP instead of HTTPS. It’s no secret that authorities here are not big fan of encryption when it is connections coming in or out of China.
So we replace:
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=API_KEY&sensor=SET_TO_TRUE_OR_FALSE"> </script>
By:
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=API_KEY&sensor=SET_TO_TRUE_OR_FALSE"> </script>
And now the map load every time without freezing the website!
Hey Martin, we’re facing the same issue now. Does your work-around still work?
Thanks.
Hello Adrian,
Sorry for the late reply.
Unfortunately *.google.com is now completely blocked in China and it’s probably definitive š . I updated the article accordingly.
We now need to use Google’s Chinese clone Baidu or other China-based service providers to have a map displaying correctly for China-based users.
Cheers,
https://developers.google.com/maps/faq#china_ws_access has a workaround.
Thank you Dan, I updated my article!