共用方式為


Geolocation 類別

定義

提供取得裝置目前位置的方法。

public ref class Geolocation abstract sealed
public static class Geolocation
type Geolocation = class
Public Class Geolocation
繼承
Geolocation

屬性

Default

提供此 API 靜態使用的預設實作。

IsListeningForeground

指出應用程式在前景時,目前是否正在接聽位置更新。

方法

GetLastKnownLocationAsync()

傳回裝置的最後一個已知位置。

GetLocationAsync()

傳回裝置的目前位置。

GetLocationAsync(GeolocationRequest)

傳回裝置的目前位置。

GetLocationAsync(GeolocationRequest, CancellationToken)

傳回裝置的目前位置。

StartListeningForegroundAsync(GeolocationListeningRequest)

使用 LocationChanged 事件或 ListeningFailed 事件開始接聽位置更新。 只有在應用程式位於前景時,才會傳送事件。 來自使用者的要求 Permissions.LocationWhenInUse

StopListeningForeground()

當應用程式位於前景時,停止接聽位置更新。 在未接聽 且 IsListeningForeground 目前 false為時沒有任何作用。

事件

ListeningFailed

在接聽位置更新期間發生錯誤時發生。 引發事件時,接聽已停止進一步的位置更新,而且不會傳送任何進一步 LocationChanged 的事件。

LocationChanged

在接聽位置更新時發生。

適用於