2012-04-18 67 views
6

我尝试按照此页:使用谷歌API - 的GClientGeocoder()

http://melandri.net/2009/07/03/get-location-coordinates-using-google-maps/ 

,但没有定义的GClientGeocoder() - 存在错误。

我已经我们我的页面上的谷歌地图API:

<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=<%=System.Web.Configuration.WebConfigurationManager.AppSettings["myGoogleKey"]%>&sensor=false"></script> 

如何解决我的错误?

这里是我succesfuly使用API​​:

var map = new google.maps.Map(document.getElementById("map_canvas"), 
     myOptions); 

回答

19

GClientGeocoder()是第2版的对象。您正在加载版本3 API并需要使用版本3对象和方法。

版本3的等价物是google.maps.Geocoder()并且被描述为in the documentation。这不同于第2版的实施。