重複の可能性:
wp7でGPS座標のアドレス名を取得する方法
WP8アプリケーションを開発しています。私のアプリケーションでは、地理座標から場所名などの特定の場所の詳細を取得したいと思います。デバイスの現在のGPS位置を取得できます。しかし、それは地理座標のみを与えます。地理座標から場所の詳細を提供するサービスはありますか?私を助けてください。
重複の可能性:
wp7でGPS座標のアドレス名を取得する方法
WP8アプリケーションを開発しています。私のアプリケーションでは、地理座標から場所名などの特定の場所の詳細を取得したいと思います。デバイスの現在のGPS位置を取得できます。しかし、それは地理座標のみを与えます。地理座標から場所の詳細を提供するサービスはありますか?私を助けてください。
あなたが探しているのは逆ジオコーディングと呼ばれています。地理座標を住所に変換します。
前に述べたように、WP7でGoogleとBingを使用してそれを実現できます。Windows Phone 8では、フレームワークの一部としてジオコーディングと逆ジオコーディングがサポートされています。このNokiaの紹介記事(「Geocoding」の下)でGeoCodingの概要を読み、この他のNokiaの記事でより包括的な概要を読むことができます。
座標から住所に変換する逆ジオコーディングの例を次に示します。
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でこのコードスニペットを実行すると、次のメッセージボックスが表示されます。
はい、bingAPIを使用して特定の場所の詳細を取得できます。 http://msdn.microsoft.com/en-us/library/ff701722.aspx http://stackoverflow.com/questions/9109996/getting-location-name-from-longitude-and-latitude-in-bingmap
これがお役に立てば幸いです。
ケルビン