Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有字符串 - “莫斯科”。
如何从我的字符串中获取 Gpoint(坐标)?
我需要以下结果:新 GPoint(30.3112,59.99322);
好吧,v2 API 说 GPoint不能用地理坐标表示地球上的一个点,但 GLatLng 可以。
要获取坐标,您需要使用地理编码:
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/