如何从街道地址坐标 [英] how to get coordinates from street address
问题描述
我工作在Windows Phone 8应用程序,但我找不到,如何让坐标形成的地址。
问题是,我有我的coordiantes,我需要我和一些地址之间的计算距离。
I'm working on windows phone 8 app, but i can't find, how to get coordinates form address. Problem is, i have my coordiantes, and i need to calculate distance between me and some address.
的Windows Phone 8不记录多,所以请。帮我
windows phone 8 is not documented that much, so please help me.
推荐答案
您正在寻找的被称为地理编码是什么:转换一个地址会有地理座标。
What you're looking for is called "geocoding": Converting an address to GeoCoordinate.
正如之前提到的,你可以使用谷歌和Bing的WP7来实现这一点。在Windows Phone 8地理编码和反向地理编码的支持作为框架的一部分。你可以阅读在本诺基亚的介绍文章的概述,以地理编码(地理编码下)而这个其他诺基亚在文章更全面地了解 。
As was mentioned before you can use Google and Bing on WP7 to achieve that. On windows phone 8 Geocoding and Reverse Geocoding are supported as part of the framework. You can read an overview to GeoCoding at this Nokia intro article (under "Geocoding") and a more comprehensive overview at this other Nokia article.
下面的地理编码从一个地址转换为坐标的例子:
Here's an example of Geocoding converting from an address to coordinates:
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运行该代码片段出现以下消息框:
When I run this code snippet on my WP8 I get the following messagebox:
这篇关于如何从街道地址坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!