2011-06-16 48 views
1

我有字符串 - “莫斯科”。如何在Google Maps API中按城市获得GPOINT Javascript

如何从我的字符串中获得Gpoint(coords)?

我需要的结果是:new GPoint(30.3112,59.99322);

+0

的API版本您使用的? – 2011-06-16 10:47:02

+0

@Yuri Stuken,v2 – 2011-06-16 10:48:10

+0

@Yuri v2可以从类名“GPoint”推导出来 - v3使用'google.maps.'命名空间 – mkilmanas 2011-06-16 10:53:53

回答

2

那么,v2的API说,GPoint does not represent地球坐标点,但GLatLng。

要获得坐标,你需要geocoding使用:

geocoder = new GClientGeocoder(); 
geocoder.getLatLng("Moscow", function(point) 
{ 
    if (point == null) 
    { 
     // nothing found 
    } 
    else 
    { 
     // point is an instance of GLatLng with coordinates you need 
    } 
}); 
相关问题