我有以下代码可以检索我存储在 Google Firestore 中的坐标:
let locationsRef = db.collection("locatioInfo")
locationsRef.getDocuments { (querySnapshot, err) in
if let err = err {
print("Error receiving Firestore snapshot: \(err)")
} else {
for document in querySnapshot!.documents {
print("\(document.documentID) => \(document.data())")
}
}
}
Run Code Online (Sandbox Code Playgroud)
产生这个输出:
location1 => ["geopoint": <FIRGeoPoint: (50.086421, 14.452333)>]
location2 => ["geopoint": <FIRGeoPoint: (50.086442, 14.452268)>]
Run Code Online (Sandbox Code Playgroud)
我的问题是:如何将获取的数据FIRGeoPoints转换为CLLocationCoordinates2D或简单地转换为:如何使用这些坐标并将它们显示在地图上?
我有一个MKAnnotationView已经设置好的广告,将它用于硬编码坐标,现在我需要显示获取的坐标。希望这足够清楚,提前致谢。