我正在尝试在Tinder或Bumble这样的用户半径内加载所有用户。但是,我当前的功能根本不按位置过滤。
我查看了GeoFirestore的文档,但不确定如何处理此问题。
let geoFirestoreRef = Firestore.firestore().collection("users")
let geoFirestore = GeoFirestore(collectionRef: geoFirestoreRef)
let userCenter = CLLocation(latitude: userLat, longitude: userLong)
let radiusQuery = geoFirestore.query(withCenter: userCenter, radius: 1)
radiusQuery.geoFirestore.getCollectionReference().whereField("Age", isGreaterThanOrEqualTo: minAge).whereField("Age", isLessThanOrEqualTo: maxAge).getDocuments { (snapshot, err) in
if let err = err {
print("failed to fetch user", err)
self.hud.textLabel.text = "Failed To Fetch user"
self.hud.show(in: self.view)
self.hud.dismiss(afterDelay: 2)
return
}
let userDictionary = documentSnapshot.data()
let user = User(dictionary: userDictionary)
我想获取给定半径内的所有用户;但是,当前,此功能正在获取所有用户,而不管位置如何。有什么建议吗?