Reverse Geocoding in Windows Phone 8

This is a support post for the Inside Windows Phone show on location and mapping in Windows Phone 8 published here.

Reverse geocoding is the process of getting an address from a latitude/longitude pair. With Windows Phone, this process is not only easy, it works in conjunction with the offline mapping capability so that developers can query addresses from a geocoordinate even when there is no data signal available.

The process is extremely straightforward: Add the namespace

using Microsoft.Phone.Maps.Services;

And create a new ReverseGeocodeQuery, give it a valid GeoCoordinate and set up the an event handler to manage the result.

ReverseGeocodeQuery reverseGeocode = new ReverseGeocodeQuery();
reverseGeocode.GeoCoordinate = new GeoCoordinate(47.60887, -122.34094);
reverseGeocode.QueryCompleted += reverseGeocode_QueryCompleted;

Then in our event handler we will get a result (or list of possible results) back as a MapAddress object.

void reverseGeocode_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
    MapAddress geoAddress = e.Result[0].Information.Address;           

This object will contain a nice helpful set of properties that we can then use to construct a valid address.


Comments (3)

  1. Sukhdev says:

    Hi, I always get e.Result.Count as zero. I am testing using window phone emulator WVGA 512MB.

  2. rox says:

    Are you sure about the part with the no data signal available? I get an empty list in the Result when I disconnect from internet.

  3. fint says:

    @rox You need to install offline maps.

Skip to main content