In order to fetch detailed information such as street address or the city name for a location, you will need to use the reverseGeo lazy-source property of the viv.geo.GeoPoint structure available in the viv.geo library capsule. Let's take a look at the steps to take for a full implementation.
By following the documentation of viv.geo library, it is easy to get a viv.geo.GeoPoint concept with the following code.
input(myPoint){
type(geo.GeoPoint)
min(Required)max(One)
default-init{
intent{
goal:geo.GeoPoint
route:geo.CurrentLocation
}
}
}
However, the GeoPoint only contains the latitude and longitude. This is because more detailed properties are not available up-front. While it may add some complexity, lazy properties increase the efficiency of your capsule by only requesting large amounts of information when you absolutely need it.
In order to get detailed current location, such as street name, you must fetch the lazy property reverseGeo from viv.geo.GeoPoint. The following code is an example of how to use the reverseGeo property.
computed-input(address){
type(geo.Address)
min(Required)max(One)
compute{
intent{
goal:geo.Address
value:$expr(myPoint.reverseGeo)
}
}
}
As the following screenshot shows, we now have access to a lot more location information than just the latitude and longitude!
Comments
0 comments
Please sign in to leave a comment.