現在の緯度と経度を地図上の住所に変換する必要がある Windows Phone アプリケーションを開発しています。GoogleMaps.LocationServices Nu Get パッケージを使用して、地図を指す住所に地理座標を変換する方法。
1 に答える
1
GoogleMaps.LocationServices NuGet パッケージには、番地を検索するメソッドがありません。以下のコードを試してください。
const string API_ADDRESS_FROM_LATLONG = "http://maps.googleapis.com/maps/api/geocode/xml?latlng={0},{1}&sensor=false";
public void GetAddressFromLatLong(string Lat, string Long)
{
try
{
var webClient = new WebClient();
webClient.DownloadStringAsync(new Uri(string.Format(API_ADDRESS_FROM_LATLONG, Lat, Long)));
webClient.DownloadStringCompleted += webClient_DownloadStringCompleted;
}
catch (Exception)
{
}
}
void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
try
{
XDocument doc = XDocument.Parse(e.Result);
var Address = doc.Descendants("result").FirstOrDefault().Descendants("formatted_address").FirstOrDefault().Value;
MessageBox.Show(Address);
}
catch (Exception)
{
}
}
于 2013-10-30T10:46:43.970 に答える