Lark Guo
Lark Guo

Reputation: 41

How should I use Google Maps API in China?

Maybe you know in China there are many services/products of Google banned, so that's so bad that as a developer can't use so great services and products. Like now I meet a problem on Google map. I need to get the longitude and latitude by a known place, but even I use the ditu.google.cn service, the function as below still will request to maps.googleapis.com which should have been banned,

 var geocoder = new GClientGeocoder();

 var latlng = geocoder.getLatLng(location,function(point) {   

      if (!point) 
      {        
        alert(location + " not found");      
      }
      else 
      {                 
         window.map.setZoom(13);  
         var marker = new GMarker(point);  
         markersArray.push(marker);           
         map.addOverlay(marker);    
         marker.openInfoWindowHtml(address);            
      }

 });

Who can give me some advice to solve this obstacle. Thanks very much.

Upvotes: 1

Views: 2853

Answers (1)

kevinterrobang
kevinterrobang

Reputation: 428

Google maps works in China. You just have to use a different base URL.

From their website: The Google Maps APIs are served within China from https://maps.google.cn. When serving content to China, replace https://maps.googleapis.com with https://maps.google.cn.

<script src="https://maps.google.cn/maps/api/js?key=API_KEY"
  type="text/javascript">
</script>

Upvotes: 3

Related Questions