[英]How to get name of street or address via Longitude and Latitude on window phone sdk
C#-如果我們知道經度和緯度,請告訴我如何獲取街道名稱或地址。
使用ReverseGeoCoding,它是Windows Phone OS版本8中sdk的一部分
反向地理編碼采用緯度和經度,並返回字符串地址或這些點在地球上的位置。
檢查此鏈接
這也
原始用法
ReverseGeocodeQuery reverseGeocode = new ReverseGeocodeQuery();
reverseGeocode.GeoCoordinate = new GeoCoordinate(gCordinate.Latitude, gCordinate.Longitude);
reverseGeocode.QueryCompleted += reverseGeocode_QueryCompleted;
reverseGeocode.QueryAsync();
void reverseGeocode_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
{
try
{
if (e.Cancelled)
{
txtCompleteAddress.Text = "operation was cancelled";
}
else if (e.Error != null)
{
txtCompleteAddress.Text = "Error: " + e.Error.Message;
}
else if (e.Result != null)
{
if (e.Result.Count > 0)
{
MapAddress geoAddress = e.Result[0].Information.Address;
addressString1 = geoAddress.HouseNumber + " " + geoAddress.Street;
addressString2 = geoAddress.District + ", " + geoAddress.City;
addressString3 = geoAddress.Country;
if (addressString1 != " ")
addressString1 = addressString1 + "\n";
else
addressString1 = "";
if (addressString2 != ", ")
addressString2 = addressString2 + "\n";
else
addressString2 = "";
txtCompleteAddress.Text = addressString1 + addressString2 + addressString3;
}
else
{
txtCompleteAddress.Text = "no address found at that location";
}
}
}
catch
{
MessageBox.Show("Some error occured in converting location geo Coordinates to location address, please try again later");
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.