location.get 是节点命令(通过 node.invoke),默认关闭。

设置模型

每个节点设备独立配置:

  • location.enabledMode: off | whileUsing
  • location.preciseEnabled: bool

UI 行为:选择 whileUsing 请求前台权限;若 OS 拒绝,回退到最高已授权级别。

命令:location.get

{
  "timeoutMs": 10000,
  "maxAgeMs": 15000,
  "desiredAccuracy": "coarse|balanced|precise"
}

响应 payload:

{
  "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应用在后台但仅有 While Using 权限
LOCATION_TIMEOUT规定时间内未获取到定位
LOCATION_UNAVAILABLE系统故障/无提供者

平台差异

  • iOS/macOS:支持 While Using 或 Always(系统设置决定)
  • Android:当前仅支持前台定位;后台调用直接拒绝
  • 精确位置是独立授权(iOS 14+ “Precise”,Android “fine” vs “coarse”)

CLI 辅助

openclaw nodes location get --node <id>
openclaw nodes location get --node <id> --accuracy precise --max-age 15000 --location-timeout 10000

工具集成

  • 工具面:nodes 工具添加 location_get 动作(需要节点)
  • Agent 准则:仅在用户启用位置且了解范围时调用

相关页面