问题描述
我已经使用 CL 位置管理器获得了用户自己的用户位置。此位置也已在“koordinaten”的 Firebase 数据库中。 现在我想获取当前用户的用户坐标并查找同一区域中的用户。如果是,他们应该在当前用户的地图上获得一个 Pin 图。
let db = Firestore.firestore()
db.collection("users").whereField("uid",isEqualTo: Auth.auth().currentUser?.uid ?? "x")
.getDocuments { (querySnapshot,err) in
let location = querySnapshot!.documents[0].get("koordinaten")
let geofire = GeoFire(firebaseRef: querySnapshot!.documents[0].get("koordinaten") as! DatabaseReference)
let center = CLLocation(coder: location as! NSCoder)
let circleQuery = geofire.query(at: center!,withRadius: 5000000000000000000000000000);
var queryHandle = circleQuery.observe(.keyEntered) { (key: String!,location: CLLocation!) in
print("Key '\(String(describing: key))' entered the search area and is at location '\(String(describing: location))'")
let newPin = MKPointAnnotation()
newPin.coordinate = location.coordinate
self.MapView.addAnnotation(newPin)
}
}
但它实际上并没有像它应该的那样工作。有谁知道如何解决这个问题? 我知道有类似的问题……但是 Retrieving Keys From GeoFire within Radius in Swift 中的示例代码在我的应用中不起作用?令人沮丧。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)