GeolocationExtensions.GetLocationAsync 方法

定义

重载

GetLocationAsync(IGeolocation)

返回设备的当前位置。

GetLocationAsync(IGeolocation, GeolocationRequest)

返回设备的当前位置。

GetLocationAsync(IGeolocation)

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

返回设备的当前位置。

public:
[System::Runtime::CompilerServices::Extension]
 static System::Threading::Tasks::Task<Microsoft::Maui::Devices::Sensors::Location ^> ^ GetLocationAsync(Microsoft::Maui::Devices::Sensors::IGeolocation ^ geolocation);
public static System.Threading.Tasks.Task<Microsoft.Maui.Devices.Sensors.Location?> GetLocationAsync (this Microsoft.Maui.Devices.Sensors.IGeolocation geolocation);
static member GetLocationAsync : Microsoft.Maui.Devices.Sensors.IGeolocation -> System.Threading.Tasks.Task<Microsoft.Maui.Devices.Sensors.Location>
<Extension()>
Public Function GetLocationAsync (geolocation As IGeolocation) As Task(Of Location)

参数

geolocation
IGeolocation

调用此方法时所针对的对象。

返回

包含 Location 当前位置信息的对象; null 如果无法确定位置,则为 。

注解

如果需要,将在运行时请求位置权限。 可能仍需要在应用清单中声明某些内容。

适用于

GetLocationAsync(IGeolocation, GeolocationRequest)

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

返回设备的当前位置。

public:
[System::Runtime::CompilerServices::Extension]
 static System::Threading::Tasks::Task<Microsoft::Maui::Devices::Sensors::Location ^> ^ GetLocationAsync(Microsoft::Maui::Devices::Sensors::IGeolocation ^ geolocation, Microsoft::Maui::Devices::Sensors::GeolocationRequest ^ request);
public static System.Threading.Tasks.Task<Microsoft.Maui.Devices.Sensors.Location?> GetLocationAsync (this Microsoft.Maui.Devices.Sensors.IGeolocation geolocation, Microsoft.Maui.Devices.Sensors.GeolocationRequest request);
static member GetLocationAsync : Microsoft.Maui.Devices.Sensors.IGeolocation * Microsoft.Maui.Devices.Sensors.GeolocationRequest -> System.Threading.Tasks.Task<Microsoft.Maui.Devices.Sensors.Location>
<Extension()>
Public Function GetLocationAsync (geolocation As IGeolocation, request As GeolocationRequest) As Task(Of Location)

参数

geolocation
IGeolocation

调用此方法时所针对的对象。

request
GeolocationRequest

确定设备位置时要使用的条件。

返回

包含 Location 当前位置信息的对象; null 如果无法确定位置,则为 。

注解

如果需要,将在运行时请求位置权限。 可能仍需要在应用清单中声明某些内容。

适用于