我有字符串 - “莫斯科”。如何在Google Maps API中按城市获得GPOINT Javascript
如何从我的字符串中获得Gpoint(coords)?
我需要的结果是:new GPoint(30.3112,59.99322);
我有字符串 - “莫斯科”。如何在Google Maps API中按城市获得GPOINT Javascript
如何从我的字符串中获得Gpoint(coords)?
我需要的结果是:new GPoint(30.3112,59.99322);
那么,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
}
});
的谷歌地理编码API将做的工作适合你,描述和例子在这里: http://code.google.com/apis/maps/documentation/geocoding/
的API版本您使用的? – 2011-06-16 10:47:02
@Yuri Stuken,v2 – 2011-06-16 10:48:10
@Yuri v2可以从类名“GPoint”推导出来 - v3使用'google.maps.'命名空间 – mkilmanas 2011-06-16 10:53:53