如何获取当前位置的详细街道名称?

How to get the detailed street name of current location?

按照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
        }
      }
    }

有两种方法:

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

这是模拟器结果

  1. reverseGeo是viv.geo.GeoPoint的lazy-sourced属性,下面的代码是如何访问它的例子。有关此主题的更多信息,可以单击 here
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