我正在尝试转换从 Firebase 检索的字符串,并将其添加为 Google 地图上的多个注释。不幸的是,我的应用程序在通过当前代码时崩溃:
ref = FIRDatabase.database().reference()
ref.child("Locations").observeSingleEventOfType(.Value, withBlock: { (snapshot) in
let lat = (snapshot.value!["Latitude"] as! NSString).doubleValue
let lon = (snapshot.value!["Longitude"] as! NSString).doubleValue
let complainLoc = CLLocationCoordinate2DMake(lat, lon)
let Coordinates = CLLocationCoordinate2D(latitude: lat, longitude: lon)
})
Run Code Online (Sandbox Code Playgroud)
这是我用于将数据保存到 Firebase 的代码
FIRDatabase.database().reference().child("Location").child(FIRAuth.auth()!.currentUser!.uid).setValue(["Latitude": locationManager.location!.coordinate.latitude, "Longitude": locationManager.location!.coordinate.longitude])
Run Code Online (Sandbox Code Playgroud)