共用方式為


GeolocationExtensions.GetLocationAsync 方法

定義

多載

GetLocationAsync(IGeolocation)

傳回裝置的目前位置。

GetLocationAsync(IGeolocation, GeolocationRequest)

傳回裝置的目前位置。

GetLocationAsync(IGeolocation)

傳回裝置的目前位置。

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)

傳回裝置的目前位置。

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 無法判斷任何位置,則為 。

備註

如有需要,將會在運行時間要求位置許可權。 您可能仍然需要在應用程式指令清單中宣告某個專案。

適用於