> ## Documentation Index
> Fetch the complete documentation index at: https://docs2.openclaw.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 位置命令

## 简要概览

* `location.get` 是节点命令，通过 `node.invoke` 或 `openclaw nodes location get` 调用。
* 默认关闭。
* Android 第三方构建使用选择器：关闭 / 使用期间 / 始终。Play 构建保持为关闭 / 使用期间。
* 精确位置是单独的开关。

## 为什么使用选择器（而不只是开关）

操作系统的位置权限是多级的。精确位置也是单独的操作系统授权（iOS 14+ 的“精确”，Android 的“fine” 与“coarse”）。应用内选择器会驱动请求的模式，但操作系统仍会决定实际授权。

## 设置模型

按节点设备：

* `location.enabledMode`: `off | whileUsing | always`
* `location.preciseEnabled`: bool

UI 行为：

* 选择 `whileUsing` 会请求前台权限。
* 在 Android 第三方构建中选择 `always` 会先请求前台权限，说明后台访问，然后打开 Android 应用设置以授予单独的 **始终允许** 权限。
* Android Play 构建不会声明后台位置权限，也不会显示 `always`。
* 如果操作系统拒绝所请求的级别，应用会回退到已授予的最高级别并显示状态。

## 权限映射（node.permissions）

可选。macOS 节点会通过 `node.list`/`node.describe` 上的 `permissions` 映射报告 `location`；iOS/Android 可能会省略它。

## 命令：`location.get`

通过 `node.invoke` 调用，或使用 CLI 辅助命令：

```bash theme={"theme":{"light":"min-light","dark":"min-dark"}}
openclaw nodes location get --node <idOrNameOrIp>
openclaw nodes location get --node <idOrNameOrIp> --accuracy precise --max-age 15000 --location-timeout 10000
```

参数：

```json theme={"theme":{"light":"min-light","dark":"min-dark"}}
{
  "timeoutMs": 10000,
  "maxAgeMs": 15000,
  "desiredAccuracy": "coarse|balanced|precise"
}
```

CLI 标志直接映射：`--location-timeout` -> `timeoutMs`，`--max-age` -> `maxAgeMs`，`--accuracy` -> `desiredAccuracy`。

响应载荷：

```json theme={"theme":{"light":"min-light","dark":"min-dark"}}
{
  "lat": 48.20849,
  "lon": 16.37208,
  "accuracyMeters": 12.5,
  "altitudeMeters": 182.0,
  "speedMps": 0.0,
  "headingDeg": 270.0,
  "timestamp": "2026-01-03T12:34:56.000Z",
  "isPrecise": true,
  "source": "gps|wifi|cell|unknown"
}
```

错误（稳定代码）：

* `LOCATION_DISABLED`：选择器已关闭。
* `LOCATION_PERMISSION_REQUIRED`：缺少所请求模式的权限。
* `LOCATION_BACKGROUND_UNAVAILABLE`：应用在后台，但只授予了“使用期间”权限。
* `LOCATION_TIMEOUT`：未及时获取定位。
* `LOCATION_UNAVAILABLE`：系统故障或没有提供商。

## 后台行为

* Android 第三方构建仅在用户选择 `Always` 且 Android 已授予后台位置权限时，才接受后台 `location.get`。现有的持久节点服务会添加 `location` 服务类型，并在活动时披露 `Location: Always`。
* Android Play 构建和 `While Using` 模式会在后台时拒绝 `location.get`。
* 其他节点平台可能不同。

## 模型/工具集成

* 智能体工具：`nodes` 工具的 `location_get` 动作（必须指定节点）。
* CLI：`openclaw nodes location get --node <id>`。
* 智能体指南：仅在用户已启用位置并理解范围时调用。

## UX 文案（建议）

* 关闭：“位置共享已禁用。”
* 使用期间：“仅当 OpenClaw 打开时。”
* 始终：“允许在 OpenClaw 处于后台时执行请求的位置检查。”
* 精确：“使用精确 GPS 位置。关闭以共享大致位置。”

## 相关

* [节点概览](/zh-CN/nodes)
* [频道位置解析](/zh-CN/channels/location)
* [相机拍摄](/zh-CN/nodes/camera)
* [Talk 模式](/zh-CN/nodes/talk)
