在 Swift 的 Radius 范围内从 GeoFire 检索密钥
Retrieving Keys From GeoFire within Radius in Swift
我有以下 Firebase 数据库 JSON 数据结构:
{
"Post List" : {
"-KUlvg8mCEGfY5ZSKCou" : {
"addedByUser" : "7llQbPdy2NV7aO337h7ap0qLOhC3",
"content" : "Post1",
"cost" : "0",
"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 查询,它将 return 1KM 半径内的所有键 [FIRAutoID's],例如在 "User Locations" 中,这些 Post 是静态的,一旦设置了用户位置,它也会被固定。从我期望的半径查询结果 return "-KUlvg8mCEGfY5ZSKCou" 所以我可以参考 Post 细节。希望这是有道理的。非常感谢,D。在网上找不到很多关于 GeoFire 的信息...看起来它仍处于初始阶段?...
想通了
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!")
})
}
这似乎给了我我需要的东西。现在将这些键引用到 FBDB 的其他部分。 :)
我有以下 Firebase 数据库 JSON 数据结构:
{
"Post List" : {
"-KUlvg8mCEGfY5ZSKCou" : {
"addedByUser" : "7llQbPdy2NV7aO337h7ap0qLOhC3",
"content" : "Post1",
"cost" : "0",
"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 查询,它将 return 1KM 半径内的所有键 [FIRAutoID's],例如在 "User Locations" 中,这些 Post 是静态的,一旦设置了用户位置,它也会被固定。从我期望的半径查询结果 return "-KUlvg8mCEGfY5ZSKCou" 所以我可以参考 Post 细节。希望这是有道理的。非常感谢,D。在网上找不到很多关于 GeoFire 的信息...看起来它仍处于初始阶段?...
想通了
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!")
})
}
这似乎给了我我需要的东西。现在将这些键引用到 FBDB 的其他部分。 :)