如何从街道地址获取坐标

我正在使用Windows Phone 8应用程序,但我找不到,如何获取坐标表格地址。 问题是,我有我的coordiantes,我需要计算我和一些地址之间的距离。

windows phone 8没有记录那么多,所以请帮帮我。

您正在寻找的是“地理编码”:将地址转换为GeoCoordinate。

如前所述,您可以在WP7上使用Google和Bing来实现这一目标。 在Windows Phone 8上支持地理编码和反向地理编码作为框架的一部分。 您可以在此诺基亚简介文章 (“地理编码”下)阅读GeoCoding概述,并在此诺基亚 其他文章中查看更全面的概述。

以下是地理编码从地址转换为坐标的示例:

private void Maps_GeoCoding(object sender, RoutedEventArgs e) { GeocodeQuery query = new GeocodeQuery() { GeoCoordinate = new GeoCoordinate(0, 0), SearchTerm = "Ferry Building, San-Francisco" }; query.QueryCompleted += query_QueryCompleted; query.QueryAsync(); } void query_QueryCompleted(object sender, QueryCompletedEventArgs> e) { StringBuilder sb = new StringBuilder(); sb.AppendLine("Ferry Building Geocoding results..."); foreach (var item in e.Result) { sb.AppendLine(item.GeoCoordinate.ToString()); sb.AppendLine(item.Information.Name); sb.AppendLine(item.Information.Description); sb.AppendLine(item.Information.Address.BuildingFloor); sb.AppendLine(item.Information.Address.BuildingName); sb.AppendLine(item.Information.Address.BuildingRoom); sb.AppendLine(item.Information.Address.BuildingZone); sb.AppendLine(item.Information.Address.City); sb.AppendLine(item.Information.Address.Continent); sb.AppendLine(item.Information.Address.Country); sb.AppendLine(item.Information.Address.CountryCode); sb.AppendLine(item.Information.Address.County); sb.AppendLine(item.Information.Address.District); sb.AppendLine(item.Information.Address.HouseNumber); sb.AppendLine(item.Information.Address.Neighborhood); sb.AppendLine(item.Information.Address.PostalCode); sb.AppendLine(item.Information.Address.Province); sb.AppendLine(item.Information.Address.State); sb.AppendLine(item.Information.Address.StateCode); sb.AppendLine(item.Information.Address.Street); sb.AppendLine(item.Information.Address.Township); } MessageBox.Show(sb.ToString()); } 

当我在WP8上运行此代码片段时,我得到以下消息框:

MEssageBox显示渡轮大楼的详细信息

你有几个选项,我用来完成这个选项的是使用网络服务,GOOGLE,BING,YAHOO等。

在Bing上(Cus用于Windows手机)你需要一把钥匙来访问地图api你可以在http://www.microsoft.com/maps/developers/mobile.aspx上获得密钥

一旦你有了密钥,就可以加入用于BING的WP7.1 SDK,或者如果这对你不起作用,请使用Rest服务上的位置api http://msdn.microsoft.com/en-us/library/ff701715.aspx

Bing Maps REST服务还提供从给定地址获取Lat / Long的function,可以在MSDN上找到更多信息

你需要在这里获得一个Bind Maps键…