Cloud Training (Online)

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.


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