Windows Dev Center

Geolocator.GetGeopositionAsync | getGeopositionAsync methods

Starts an asynchronous operation to retrieve the current location.

Overload list

MethodDescription
GetGeopositionAsync() Starts an asynchronous operation to retrieve the current location of the device.
GetGeopositionAsync(TimeSpan, TimeSpan) Starts an asynchronous operation to retrieve the current location of the device.

Remarks

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 Insider Preview)
  • The location services setting, Location, is turned on
  • Under Choose apps that can use your location, your app is set to on
Important  

Starting in Windows 10 Insider Preview, 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.

Requirements

Minimum supported client

Windows 8

Minimum supported server

None supported

Minimum supported phone

Windows Phone 8

Namespace

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

Metadata

Windows.winmd

Capabilities

ID_CAP_LOCATION [Windows Phone]

See also

Geolocator
Detect a user's location
Respond to location updates
Set up a geofence
Windows 10 Insider Preview geolocation sample
Windows 8.1 geolocation sample

 

 

Show:
© 2015 Microsoft