Share via


Geolocation.GetLocationAsync Method

Definition

Overloads

GetLocationAsync()

Returns the current location of the device.

GetLocationAsync(GeolocationRequest)

Returns the current location of the device.

GetLocationAsync(GeolocationRequest, CancellationToken)

Returns the current location of the device.

GetLocationAsync()

Source:
Geolocation.shared.cs
Source:
Geolocation.shared.cs

Returns the current location of the device.

public:
 static System::Threading::Tasks::Task<Microsoft::Maui::Devices::Sensors::Location ^> ^ GetLocationAsync();
public static System.Threading.Tasks.Task<Microsoft.Maui.Devices.Sensors.Location?> GetLocationAsync ();
static member GetLocationAsync : unit -> System.Threading.Tasks.Task<Microsoft.Maui.Devices.Sensors.Location>
Public Shared Function GetLocationAsync () As Task(Of Location)

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.

Applies to

GetLocationAsync(GeolocationRequest)

Source:
Geolocation.shared.cs
Source:
Geolocation.shared.cs

Returns the current location of the device.

public:
 static System::Threading::Tasks::Task<Microsoft::Maui::Devices::Sensors::Location ^> ^ GetLocationAsync(Microsoft::Maui::Devices::Sensors::GeolocationRequest ^ request);
public static System.Threading.Tasks.Task<Microsoft.Maui.Devices.Sensors.Location?> GetLocationAsync (Microsoft.Maui.Devices.Sensors.GeolocationRequest request);
static member GetLocationAsync : Microsoft.Maui.Devices.Sensors.GeolocationRequest -> System.Threading.Tasks.Task<Microsoft.Maui.Devices.Sensors.Location>
Public Shared Function GetLocationAsync (request As GeolocationRequest) As Task(Of Location)

Parameters

request
GeolocationRequest

The criteria to use when determining the location of the device.

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.

Applies to

GetLocationAsync(GeolocationRequest, CancellationToken)

Source:
Geolocation.shared.cs
Source:
Geolocation.shared.cs

Returns the current location of the device.

public:
 static System::Threading::Tasks::Task<Microsoft::Maui::Devices::Sensors::Location ^> ^ GetLocationAsync(Microsoft::Maui::Devices::Sensors::GeolocationRequest ^ request, System::Threading::CancellationToken cancelToken);
public static System.Threading.Tasks.Task<Microsoft.Maui.Devices.Sensors.Location?> GetLocationAsync (Microsoft.Maui.Devices.Sensors.GeolocationRequest request, System.Threading.CancellationToken cancelToken);
static member GetLocationAsync : Microsoft.Maui.Devices.Sensors.GeolocationRequest * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Maui.Devices.Sensors.Location>
Public Shared 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.

Applies to