首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从街道地址获取坐标

如何从街道地址获取坐标
EN

Stack Overflow用户
提问于 2013-01-22 19:10:56
回答 3查看 5.4K关注 0票数 2

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

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

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2013-01-24 09:53:28

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

正如前面提到的,你可以在WP7上使用谷歌和必应来实现这一点。在windows phone 8上,地理编码和反向地理编码是框架的一部分。您可以阅读GeoCoding at this Nokia intro article的概述(在“地理编码”下)和更全面的概述at this other Nokia article

下面是一个从地址到坐标的地理编码转换示例:

代码语言:javascript
复制
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上运行这段代码时,我得到了以下消息框:

票数 8
EN

Stack Overflow用户

发布于 2013-01-22 20:52:32

你有几个选择,其中一个我用来完成这是使用一个网络服务,谷歌,必应,雅虎等。

在必应(Cus用于windows phone)上,您需要一个密钥才能访问地图应用程序接口,您可以在http://www.microsoft.com/maps/developers/mobile.aspx上获取该密钥

一旦您有了密钥,您就可以访问WP7.1SDK for BING,或者如果它对您不起作用,请使用Rest服务http://msdn.microsoft.com/en-us/library/ff701715.aspx上的location api

票数 0
EN

Stack Overflow用户

发布于 2013-01-23 16:46:24

Bing地图REST服务还提供了从给定地址获取经纬度的功能,有关详细信息,请访问MSDN here

您将需要通过here...获取绑定映射密钥

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14457247

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档