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 will learn about sync provider notifications in Windows 11 and how to disable or enable it...
In this tutorial, let’s learn how to enable or disable the startup sound in Windows 11. By default, when Windows...
The CameraCaptureTask allows the Windows Phone 7 App to launch the Camera Application . This will be useful when the...