我尝试了下面的代码来获取附近某个位置过滤的位置数据。但我不知道如何获取文件。
FirebaseApp.configure()
let db = Firestore.firestore()
let geoFirestoreRef = db.collection("spot")
let geoFirestore = GeoFirestore(collectionRef: geoFirestoreRef)
// Query using CLLocation
let center = CLLocation(latitude: 35.681236, longitude: 139.767125)
// Query locations at [37.7832889, -122.4056973] with a radius of 100km
var circleQuery = geoFirestore.query(withCenter: center, radius: 100.0)
let _ = circleQuery.observe(.documentEntered, with: { (key, location) in
geoFirestoreRef.document(key!).getDocument { (document, error) in
if let document = document, document.exists {
print(document)
} else {
print("Document does not exist.")
}
}
print("The document with documentID '\(key)' entered the search area and is at location '\(location)'")
})
circleQuery
这个变量只返回 GFSCircleQuery 对象。我不知道如何获取通过查询过滤的实际文档。