Share via


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()

当应用位于前台时,停止侦听位置更新。 不侦听时不起作用,当前IsListeningForegroundfalse为 。

事件

ListeningFailed

在侦听位置更新期间出现错误时发生。 触发事件时,已停止侦听其他位置更新,并且不会发送其他 LocationChanged 事件。

LocationChanged

侦听位置更新时发生。

适用于