IGeolocation.GetLocationAsync(GeolocationRequest, CancellationToken) 方法

定義

傳回裝置的目前位置。

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)

參數

request
GeolocationRequest

判斷裝置位置時要使用的準則。

cancelToken
CancellationToken

可用來取消作業的令牌。

傳回

Location包含目前位置資訊的物件,如果null無法判斷任何位置,則為 。

備註

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

適用於