Question

I'm doing an application in windows phone 8 and I need a function which return name of district, town district or village from GPS coordinates. It would be best if he went without connection to the internet, from maps on phone. Thanks for your response and time.

/// <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)
{

}
Was it helpful?

Solution

You can use the ReverseGeocodingQuery to get information about your current location, but it's not working offline.

To get information use following lines of code:

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

Result for GeoCoordinate 48.774010, 9.224396 would be Zur Staibhöhe Stuttgart Germany.

Btw.: The localization of the phone is being used (If the language is german, the result would be Zur Staibhöhe Stuttgart Deutschland)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top