Windows Phone 8从GPS位置获取城镇名称

时间:2014-02-16 14:46:16

标签: windows-phone-8 gps maps bing-maps

我正在windows phone 8中进行应用程序,我需要一个从GPS坐标返回地区,城镇地区或村庄名称的功能。如果他没有连接到互联网,从手机上的地图开始,那将是最好的。感谢您的回复和时间。

/// <summary>
/// Returns the name of the village
/// </summary>
/// <param name="geoCoordinate">GPS coordinate</param>
/// <returns>returns the name of the village</returns>
string NameOfPlace(GeoCoordinate geoCoordinate)
{

}

1 个答案:

答案 0 :(得分:0)

您可以使用ReverseGeocodingQuery获取有关当前位置的信息,但离线工作。

使用以下代码行获取信息:

string NameOfPlace = "";
ReverseGeocodeQuery MyReverseGeocodeQuery = null;

void GetNameOfPlace(GeoCoordinate geoCoordinate)
{
    MyReverseGeocodeQuery = new ReverseGeocodeQuery();
    MyReverseGeocodeQuery.GeoCoordinate = new GeoCoordinate(geoCoordinate.Latitude, geoCoordinate.Longitude);
    MyReverseGeocodeQuery.QueryCompleted += ReverseGeocodeQuery_QueryCompleted;
    MyReverseGeocodeQuery.QueryAsync();
}

private void ReverseGeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
{
    var result = e.Result[0];
    NameOfPlace  = result.Information.Address.Street + " " + result.Information.Address.City + " " + result.Information.Address.Country;
}

GeoCoordinate 48.774010,9.224396的结果将是ZurStaibhöheStuttgartGermany

顺便说一下:正在使用手机的本地化(如果语言是德语,结果将是ZurStaibhöheStuttgartDeutschland