2014-07-25 18 views
1

也许你知道在中国有很多谷歌的服务/产品被禁止,所以这太糟糕了,因为开发者不能使用如此优质的服务和产品。就像现在我在Google地图上遇到问题一样。我需要通过已知位置的经度和纬度,但即使我用ditu.google.cn服务,功能如下仍将请求maps.googleapis.com应该被禁止,我应该如何在中国使用Google Maps API?

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);    
     } 

}); 

谁可以给我一些建议解决这个障碍。 非常感谢。

+0

Hey Lark,你找到了解决办法吗? –

回答

3

谷歌地图在中国工作。你只需要使用不同的基本URL。

their website:Google Maps API由https://maps.google.cn在中国境内提供。向中国提供内容时,请将https://maps.googleapis.com替换为https://maps.google.cn

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

这似乎适用于某些情况,但不适用于自动填充API。从我的测试(中国境外,可能不准确),尽管我在'