IGeolocation.GetLocationAsync(GeolocationRequest, CancellationToken) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns the current location of the device.
public:
System::Threading::Tasks::Task<Microsoft::Maui::Devices::Sensors::Location ^> ^ GetLocationAsync(Microsoft::Maui::Devices::Sensors::GeolocationRequest ^ request, System::Threading::CancellationToken cancelToken);
public System.Threading.Tasks.Task<Microsoft.Maui.Devices.Sensors.Location?> GetLocationAsync (Microsoft.Maui.Devices.Sensors.GeolocationRequest request, System.Threading.CancellationToken cancelToken);
abstract member GetLocationAsync : Microsoft.Maui.Devices.Sensors.GeolocationRequest * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Maui.Devices.Sensors.Location>
Public Function GetLocationAsync (request As GeolocationRequest, cancelToken As CancellationToken) As Task(Of Location)
Parameters
- request
- GeolocationRequest
The criteria to use when determining the location of the device.
- cancelToken
- CancellationToken
A token that can be used for cancelling the operation.
Returns
A Location object containing current location information or null
if no location could be determined.
Remarks
The location permissions will be requested at runtime if needed. You might still need to declare something in your app manifest.