bixby - 如何从 $user.currentLocation 获取用户的社区或城市?
问题描述
我想知道是否有人可以帮助我解决这个问题。如何从 $user.currentLocation 获取用户的社区(或城市)?
我一直在尝试各种事情,并查看了文档,尤其是这里: https ://bixbydevelopers.com/dev/docs/dev-guide/developers/library.geo#searchregion-and-currentlocation 但这不是我正在寻找。
如果用户说:“天气怎么样?” 在不指定地点的情况下,我的 getWeather 操作如下所示:
input (where) {
min (Optional) max(One)
type (viv.geo.NamedPoint)
default-select {
with-rule {
select-first
}
}
default-init {
if ($user.currentLocation.$exists) {
intent {
goal: geo.GeoPoint
value-set: geo.CurrentLocation { $expr ($user.currentLocation) }
}
}
}
这将为我提供用于天气 API 查询的 long/lat。但我想在视图中显示(虽然不是说)用户当前位置的社区(或城市)。(我相信如果我将目标/值集更改为 SearchRegion,那么我可以获得城市,但不是 $user.currentLocation 的经度/纬度。相反,我得到城市的通用经度/纬度,这不是t足够具体。)
所以,我想要 1) API 的 $user.currentLocation 的经度/纬度和 2) 用于视图的经度/纬度的社区(或城市)。我无法弄清楚如何同时获得两者。
解决方案
您定义的输入是 aNamedPoint
并且NamedPoint.point
是 aGeoPoint
所以它应该具有您需要的纬度/经度。
要获取城市,NamedPoint.address
应该包含一个Address
结构来访问街道地址、城市、州、国家等。
另一种选择可能是获取地址的reverseGeo
属性。GeoPoint
此属性是 a lazy-source
,因此在调用此属性之前数据将不可用。
推荐阅读
- r - 如何创建多个工作簿,每个工作簿中有多个工作表
- office-ui-fabric - Fluent/Fabric - 是否可以以编程方式清除 NormalPeoplePicker 的输入?
- java - 如何使多个 nbm 模块的 jar 状态相同?
- python - 将变量打印到 txt 文件
- java - Spring Boot - 具有来自外部来源的属性的 ConditionalOnExpression
- c# - 即使使用 FirstOrDefault 的位置,EF 也会加载所有子项
- javascript - 如何为whatsapp之类的通知实现声音?
- regex - 正则表达式还添加符号
- excel - VBA Excel - 查找某一列并将其移动到 Excel 中另一列之前的列
- python - 用漂亮的汤(python)按类搜索不起作用