我尝试了下面的代码来获取由附近特定位置过滤的位置数据。 但我不知道如何获取文件。
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对象。 我不知道如何获取按查询过滤的实际文档。
答案 0 :(得分:0)
在Firebase中进行查询时,可以调用.getDocuments或类似名称。 Firebase在线提供了非常详细的文档,您可能应该从中开始。 https://firebase.google.com/docs