首页 > 解决方案 > 如何获取当前位置的详细街道名称?

问题描述

通过遵循https://bixbydevelopers.com/dev/docs/dev-guide/developers/library.geo上的示例,我可以获得 viv.geo.GeoPoint,但它只包含经度和纬度,我如何获得更详细街道名称等信息?

    input (myPoint) {
      type (geo.GeoPoint)
      min (Required) max (One)
      default-init {
        intent {
          goal: geo.GeoPoint
          route: geo.CurrentLocation
        }
      }
    }

在此处输入图像描述

标签: bixbybixbystudio

解决方案


有两种方法:

  1. 如果只想渲染细节,可以使用库默认值对话框,虽然调试器没有显示 reverseGeo 属性,但它会正确显示。考虑这个简单的结果视图:
result-view {
  match: MyGeoPoint(this) 
  message: template ("I am at [#{value(this)}]")
}

这是模拟器结果 在此处输入图像描述

  1. reverseGeo 是 viv.geo.GeoPoint 的惰性资源属性,以下代码是如何访问它的示例。有关此主题的更多信息,请单击此处
action (GetMyPoint) {
  description (debug for current GPS location)
  type (Search)
  collect {
    input (myPoint) {
      type (geo.GeoPoint)
      min (Required) max (One)
      default-init {
        intent {
          goal: geo.GeoPoint
          route: geo.CurrentLocation
        }
      }
    }
    computed-input (address) {
      type (geo.Address) 
      min (Required) max (One)
      compute {
        intent {
          goal: geo.Address
          value: $expr(myPoint.reverseGeo)
        }
      }
    }
  }
  output (MyGeoPoint) {
    evaluate {
      $expr(myPoint)
    }
  }
}

现在 reverseGeo 显示在调试器上 在此处输入图像描述


推荐阅读