我在想,也许有人能帮我解决这个问题。如何从$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查询的经度/经度。但我想在视图中显示(但不是说)用户当前位置的邻居(或城市)。(我相信如果我将目标/值设置更改为SearchRegion,那么我可以获得城市,但不能获得$user.currentLocation的经度/纬度。相反,我得到了一个通用的城市的long/lat,这还不够具体。)
因此,我需要1) API的$user.currentLocation的经度/纬度,以及2)视图的经度/纬度的邻域(或城市)。我想不出怎么才能两者兼得。
发布于 2020-07-30 08:54:57
您定义的输入是一个NamedPoint,而NamedPoint.point是一个GeoPoint,因此它应该包含您需要的经纬度。
要获取城市,NamedPoint.address应该包含一个Address结构来访问街道地址、城市、州、国家等。
另一种选择是使用GeoPoint的reverseGeo属性来获取地址。此属性是一个lazy-source,因此在调用此属性之前,数据将不可用。
https://stackoverflow.com/questions/63122359
复制相似问题