Tho*_*med -3 android google-maps firebase algolia
我正在使用Algolia的InstantSearch Android库.这是我的Query:
searcher.setQuery(new Query().setAroundLatLng(new AbstractQuery.LatLng(lat, lng)).setAroundRadius(5000)).
Run Code Online (Sandbox Code Playgroud)
如何显示获取的记录与当前位置之间的距离?
建立在@ Raphi的最佳答案之上,以下是使用InstantSearch Android显示距离的方法:您只需编写自定义命中View.
TextView实现AlgoliaHitViewonUpdateView,获得_rankingInfo.matchedGeoLocation.distanceRaphi推荐setText(distance + " meters away.")小智 5
实际上,您可以通过将参数添加getRankingInfo=true到搜索查询中来查找响应中每个匹配的距离.
我不熟悉InstantSearch Android,但如果您可以访问原始响应,那么请查看_rankingInfo.matchedGeoLocation.distance您的记录:
{
[...] // your record fields
"_rankingInfo": {
"nbTypos": 0,
"firstMatchedWord": 0,
"proximityDistance": 0,
"userScore": 11,
"geoDistance": 468,
"geoPrecision": 1,
"nbExactWords": 1,
"words": 1,
"filters": 0,
"matchedGeoLocation": {
"lat": 48.86,
"lng": 2.3443,
"distance": 468
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
352 次 |
| 最近记录: |