使用Firebase查找附近的latlng [英] Finding nearby latlng using firebase
问题描述
-uniqueid1
latitude: 30.7188235
longitude: 76.810132
-uniqueid2
latitude: 30.7188235
longitude: 76.810132
firebase中有1000条这样的记录,我想找到最接近特定long/lat的唯一标识.我开始使用startAt()和endAt()但没有成功,我们如何实现条件子句和多个查询.我在寻找的是
there are 1000 such records in firebase , I want to find uniqueids closest to a specific long/lat.I started using startAt() and endAt() but no success.How do we implement conditional clause and multiple queries.The query me looking for is
SELECT uniqueids from table where (lon-specific_lon)^2+(lat-specific_lat)^2<CONSTANT.
推荐答案
What you're looking for is part of Firebase's Geofire library. It uses Geohashes to cleverly work around Firebase's limit that you can only query on a single value.
Geohashes 是一种将经度和纬度填充为适合范围查询的单个值的方法.
Geohashes are a way to stuff longitude and latitude into a single value that is suitable for range querying.
有关更多信息,请参见 Githfire的Github存储库.
See the Github repo for Geofire for more information.
这篇关于使用Firebase查找附近的latlng的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!