编辑:看起来不再需要API密钥。
您可以使用REST APIs和解析响应(XML/JSON/CSV)。
http://maps.google.com/maps/geo?q=State+St,+Troy,+NY&output=csv&oe=utf8&sensor=false
将输出:
200,6,42.730070,-73.690570
那就是:
- - G_GEO_SUCCESS
- - 街道级精确度
- 42.730070 - 纬度
- -73.690570 - 经度
如果你不熟悉的System.Net的API,他们会去是这样的:
const string GeoCodeUrlFormat = "http://maps.google.com/maps/geo?q={0}&output=csv&oe=utf8&sensor=false";
string location = "State St, Troy, NY";
string url = String.Format(GeoCodeUrlFormat, HttpUtility.UrlEncode(location));
HttpRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
HttpResponse response = (HttpResponse)request.GetResponse(); // Can throw an exception
Stream responseStream = response.GetResponseStream();
using (StreamReader reader = new StreamReader(responseStream)
{
string firstLine = reader.ReadLine();
string[] lineParts = firstLine.Split();
GeolocationResult result = GoogleMapper.MapGeolocationResult(lineParts);
// TADA
}
显然没有错误处理,它不支持多个返回值,我没有实际实现MapGeolocationResult,但它应该给你一个开始。
非常感谢。然而问题的一部分是我想使用V3的V3(不是V2),因为它不再需要API密钥。 该应用将推出到各种客户和API密钥应链接到网络服务器,但这不会是一个Windows窗体应用程序的情况下... – Marc 2009-07-29 15:16:41