2015-10-07 24 views
0

由於某些原因,如果半徑設置爲1197或更高,我的Geofire查詢僅返回物品。更少,也不會返回任何內容。當數據返回並記錄距離時,它們都小於1km,所以這對我沒有任何意義。當設置巨大半徑時,Firebase Geofire查詢僅返回附近的物品

這個的任何想法?

代碼:

this.firebaseRef = new Firebase("<my firebase - this is fine>"); 
    this.geoFire = new GeoFire(this.firebaseRef); 

    this.geoQuery = this.geoFire.query({ 
    center: [50.72001, -1.8800], 
    radius: 1197 
    }); 

    this.geoQuery.on("key_entered", function(key, location, distance){ 
    console.log(key + ', ' + location + ', ' + distance); 
    }); 

我要提到我使用的反應,這是在componentWillMount方法。

謝謝!

更新: Geofire似乎需要一個Geohash來搜索數據庫,所以要解決我的問題,我開始將lat/lng轉換爲geohashes並將其存儲。

+0

GeoFire提供了用於保存應該以您的名義創建geohash的lat/long的方法。這些可能會有所幫助。 – Kato

回答

0

Geofire似乎需要一個Geohash來搜索數據庫,而我的只存儲了經度和緯度,所以爲了解決我的問題,我開始將lat/lng轉換爲geohashes並存儲起來。

將座標轉換爲地理散列,看到https://github.com/chrisveness/latlon-geohash,這完美地工作。

+0

使用Javascript有可能嗎?搜索靜態(固定)位置附近的密鑰(密鑰列表) - 這些位置是在Firebase數據存儲中預先添加的。 注意:不使用'key_entered',因爲'key_entered'僅在新的或位置更新時觸發。以前添加的地點,但在給定的半徑範圍內。 怎麼可能? –

+0

是的,這絕對有可能使用Geofire。我建議您查看相關文檔,因爲我沒有在Geofire工作一年多,所以不記得如何去做。 – sherlock

+0

不,沒有找到!請檢查此問題的詳細信息:http://stackoverflow.com/questions/43632746/firebase-geofire-js-how-to-get-list-of-keys-of-near-by-staticfixed-locations –