可能重複:
How to get Address name of GPS coordinate with wp7位置細節的Windows Phone 8
我developoing一個WP8 application.In我的應用程序,我想獲得一個特定的位置一樣的細節地理名稱來自其地理座標。我可以獲得設備當前的GPS位置。但它只提供地理座標。有沒有提供地理座標位置詳細信息的服務?請幫幫我。
可能重複:
How to get Address name of GPS coordinate with wp7位置細節的Windows Phone 8
我developoing一個WP8 application.In我的應用程序,我想獲得一個特定的位置一樣的細節地理名稱來自其地理座標。我可以獲得設備當前的GPS位置。但它只提供地理座標。有沒有提供地理座標位置詳細信息的服務?請幫幫我。
是的,您可以使用bing API來獲取特定的位置詳細信息。 http://msdn.microsoft.com/en-us/library/ff701722.aspx http://stackoverflow.com/questions/9109996/getting-location-name-from-longitude-and-latitude-in-bingmap
希望thsi幫助。
開爾文
它工作..謝謝 – Aneesh
你在找什麼叫做反向地理編碼。將Geocoordinate轉換爲地址。
如前所述,您可以在WP7上使用Google和Bing來實現這一點。在windows phone 8上,Geocoding和Reverse Geocoding作爲框架的一部分得到了支持。您可以閱讀GeoCoding at this Nokia intro article(在「地理編碼」下)和更全面的概述at this other Nokia article的概述。
這裏的反向地理編碼從一個座標地址轉換的例子:
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());
}
當我跑我的WP8此代碼段出現以下消息框:
我收到語句'query.QueryAsync();'異常'System.UnauthorizedAccessException'和'System.Reflection.TargetInvocationException'。這可能是什麼原因造成的? – Mayank
@Mayank檢查您的應用是否撥打多個電話,一次只能撥打一個電話,希望它有幫助 –
[如何獲取GPS座標的地址名稱與wp7](http://stackoverflow.com/questions/9294474/how-to-get-address-name-of-gps-coordinate-with-wp7) –
這不是重複的。上一個問題針對的是WP7,WP8提供了一種新的和改進的反向地理編碼查找方式。請參閱下面的@JustinAngels回答。 –