Windows Phone 8 Dev Guide – Retrieving the Current Location

If you want to retreive the current location from your Windows Phone app , you can use the GetGeopositionAsync method that is defined inn the Windows.Devices.Geolocation.Geolocator class.

How to Get the Current Location from Windows Phone 8 ?

To use the Location and Maps API in your Windows Phone 8 app , it is necessary to set the below capabilities in the WMAppManifest.xml GUI Capabilities tab of your project.

  • ID_CAP_MAPS
  • ID_CAP_LOCATION

Just create an instance of the Geolocator class and call the GetGeopositionAsync() method to return the Geoposition . The resulting Geoposition’s latitude and longitude can be used to identify the current location which can later be used to display on the map.

Below is a code snippet demonstrating the usage of the GetGeopositionAsync to get the current location.

Geolocator GKlocator = new Geolocator();    
GKlocator.DesiredAccuracy = PositionAccuracy.High; 
Geoposition position = await GKlocator.GetGeopositionAsync(); 
MessageBox.Show(position.Coordinate.Latitude + " , " + position.Coordinate.Longitude);

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you’ll learn about the Win32 Error “0x000019E5 – ERROR_COULD_NOT_RESIZE_LOG” that you get when debugging system erors in...
In this post, you’ll learn about the error “CO_E_DBERROR 0x8004E02B” that is returned when working with COM based APIs or...
In this post, you’ll learn about the Win32 Error “0x000019D0 – ERROR_LOG_BLOCK_VERSION” that you get when debugging system erors in...