問題描述
我有以下 Firebase 數(shù)據(jù)庫 JSON 數(shù)據(jù)結(jié)構(gòu):
I have the following Firebase Database JSON data structure:
{
"Post List" : {
"-KUlvg8mCEGfY5ZSKCou" : {
"addedByUser" : "7llQbPdy2NV7aO337h7ap0qLOhC3",
"content" : "Post1",
"cost" : "$450",
"duration" : "Daily",
"latitude" : "25.0879721592719",
"longitude" : "55.1487715855458",
"number" : "01234567890",
"timestamp" : "Posted on: Sun 23 Oct"
}
},
"Post Locations" : {
"-KUlvg8mCEGfY5ZSKCou" : {
".priority" : "thrnwznh58",
"g" : "thrnwznh58",
"l" : [ 25.0879721592719, 55.1487715855458 ]
}
},
"User Locations" : {
"7llQbPdy2NV7aO337h7ap0qLOhC3" : {
".priority" : "thrnwypqu9",
"g" : "thrnwypqu9",
"l" : [ 25.0829547120321, 55.1505315855337 ]
}
}
}
我希望有一個 GeoFire 查詢,它將返回 1KM 半徑內(nèi)的所有鍵 [FIRAutoID's],例如的用戶位置"這些帖子是靜態(tài)的,一旦設(shè)置了用戶位置,它也將被修復(fù).從半徑查詢結(jié)果中,我期望返回-KUlvg8mCEGfY5ZSKCou",這樣我就可以參考帖子詳細(xì)信息.希望這是有道理的.非常感謝,D.無法在網(wǎng)上找到很多關(guān)于 GeoFire 的信息...看起來它仍處于初始階段?...
I am looking to have a GeoFire query which will return all the keys [FIRAutoID's] within a radius of 1KM, for e.g. of "User Locations" these Posts are static and once the user location is set it will also be fixed. From the radius query result I am expecting to return "-KUlvg8mCEGfY5ZSKCou" so I can then make a reference the Post Details. Hope this makes sense. Many thanks, D. Cant find much online about GeoFire... looks like its still in the initial stages?...
推薦答案
想通了
func geoFireQuery() {
let circleQuery = geoFire.query(at: self.myLocation, withRadius: 0.5)
_ = circleQuery!.observe(.keyEntered, with: { (key: String?, location: CLLocation?) in
print (key!)
})
circleQuery?.observeReady({
print("All initial data has been loaded and events have been fired!")
})
}
這似乎給了我我需要的東西.現(xiàn)在將這些鍵引用到 FBDB 的另一部分.:)
this seems to be giving me what I need. Now to reference those keys to the other part of the FBDB. :)
這篇關(guān)于在 Swift 中從 Radius 中的 GeoFire 檢索密鑰的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!