【问题标题】:how to get coordinates from street address如何从街道地址获取坐标
【发布时间】:2013-01-22 11:10:55
【问题描述】:

我正在使用 windows phone 8 应用程序,但我找不到如何获取坐标表单地址。 问题是,我有我的坐标,我需要计算我和某个地址之间的距离。

windows phone 8 的文档记录不多,所以请帮助我。

【问题讨论】:

标签: c# location windows-phone-8


【解决方案1】:

您正在寻找的内容称为“地理编码”:将地址转换为地理坐标。

如前所述,您可以在 WP7 上使用 Google 和 Bing 来实现这一目标。在 windows phone 8 上,框架支持地理编码和反向地理编码。您可以阅读地理编码at this Nokia intro article 的概述(在“地理编码”下)和更全面的概述at this other Nokia article

这是一个从地址转换为坐标的地理编码示例:

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<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());
}

当我在 WP8 上运行此代码 sn-p 时,我收到以下消息框:

【讨论】:

    【解决方案2】:

    您有多种选择,我用来实现此目的的方法是使用网络服务、GOOGLE、BING、YAHOO 等。

    在 Bing 上(Cus 适用于 windows phone) 您需要密钥才能访问地图 api 您可以在以下位置获取密钥 http://www.microsoft.com/maps/developers/mobile.aspx

    一旦您拥有密钥,您就可以访问 WP7.1 SDK for BING,或者如果这不适合您,请使用 Rest Service 上的位置 API http://msdn.microsoft.com/en-us/library/ff701715.aspx

    【讨论】:

      【解决方案3】:

      Bing Maps REST 服务还提供从给定地址获取纬度/经度的功能,更多信息请访问MSDN here

      您需要通过here... 获取绑定地图密钥

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-03-03
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多