2014-02-16 68 views
0

我在做windows phone 8的應用程序,我需要一個從GPS座標返回地區,城鎮地區或村莊名稱的功能。如果他沒有連接到互聯網,那麼最好的辦法是從手機上的地圖上。感謝您的回覆和時間。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) 
{ 

} 
+0

有做脫機的API。 – WiredPrairie

回答

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; 
} 

結果爲會有地理座標48.774010,9.224396將祖爾Staibhöhe德國斯圖加特

順便說一句。:手機的定位正在使用(如果語言是德語,其結果必然是祖爾Staibhöhe斯圖加特五金

+0

工作正常,謝謝。 – Lenny