GetGeopositionAsync() | getGeopositionAsync() method
Collapse the table of content
Expand the table of content

Geolocator.GetGeopositionAsync() | getGeopositionAsync() method

Starts an asynchronous operation to retrieve the current location of the device.


Public Function GetGeopositionAsync() As IAsyncOperation(Of Geoposition)


This method has no parameters.

Return value

Type: IAsyncOperation<Geoposition>

An asynchronous operation that, upon completion, returns a Geoposition marking the found location.


This method throws an exception if the app doesn't have location permissions or if it times out with no location data retrieved. Therefore, the method should be called within a try/catch statement so that these common exception cases can be handled (see code snippet below).

This method times out after 60 seconds, except when in Connected Standby. During Connected Standby, Geolocator objects can be instantiated but the Geolocator object will not find any sensors to aggregate and calls to GetGeopositionAsync will time out after 7 seconds. Upon time out, the StatusChanged event listeners will be called once with the NoData status, and the PositionChanged event listeners will never be called.

Tip  When using the emulator, don't forget to change the location to trigger the PositionChanged event.

The user sets the privacy of their location data with the location privacy settings in the Settings app. Your app can access the user's location only when:

  • Location for this device... is turned on (not applicable to Windows 10 Mobile)
  • The location services setting, Location, is turned on
  • Under Choose apps that can use your location, your app is set to on

Starting in Windows 10, call the RequestAccessAsync before accessing the user’s location. At that time, your app must be in the foreground and RequestAccessAsync must be called from the UI thread. Until the user grants your app permission to their location, your app can't access location data.



This example shows how to call GetGeopositionAsync. For more info, see Get current location.

using Windows.Devices.Geolocation;
var accessStatus = await Geolocator.RequestAccessAsync();
switch (accessStatus) {
 case GeolocationAccessStatus.Allowed:

  // If DesiredAccuracy or DesiredAccuracyInMeters are not set (or value is 0), DesiredAccuracy.Default is used.
  Geolocator geolocator = new Geolocator { DesiredAccuracyInMeters = _desireAccuracyInMetersValue };

  // Subscribe to StatusChanged event to get updates of location status changes
  _geolocator.StatusChanged += OnStatusChanged;

  try {                        
   // Carry out the operation
   Geoposition pos = await geolocator.GetGeopositionAsync();
  } catch (Exception ex) {
   // handle the exception (notify user, etc.)

 case GeolocationAccessStatus.Denied:
  // handle access denied case here

 case GeolocationAccessStatus.Unspecified:
  // handle unspecified error case here

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0


Windows::Devices::Geolocation [C++]




Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

None supported

Minimum supported phone

Windows Phone 8


Windows::Devices::Geolocation [C++]




ID_CAP_LOCATION [Windows Phone]

See also

Get current location
GetGeopositionAsync(TimeSpan, TimeSpan)
geolocation sample



© 2016 Microsoft