Windows Phone 8中GeoCoordinates的位置详细信息

Ane*_*esh 1 windows-phone-8

可能重复:
如何使用wp7获取GPS坐标的地址名称

我正在开发一个WP8应用程序.在我的应用程序中,我想从其地理坐标中获取特定位置的详细信息,如位置名称.我可以获得设备当前的GPS位置.但它只给出了地理坐标.是否有任何服务可以提供地理坐标的位置详细信息.请帮我.

Jus*_*gel 6

您正在寻找的是反向地理编码.将Geocoordinate转换为地址.

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

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

private void Maps_ReverseGeoCoding(object sender, RoutedEventArgs e)
{
    ReverseGeocodeQuery query = new ReverseGeocodeQuery()
    {
        GeoCoordinate = new GeoCoordinate(37.7951799798757, -122.393819969147)
    };
    query.QueryCompleted += query_QueryCompleted;
    query.QueryAsync();
}

void query_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> 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());
}
Run Code Online (Sandbox Code Playgroud)

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

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