使用Firebase作为后台,我有一系列的经度坐标坐标,如何将它们转换成CLLocationCoordinate2D,以便我们可以使用它们进行注释?
以下是每次更新时从Firebase获取信息的代码
以下是每次更新时从Firebase获取信息的代码
var UpdateRef = Firebase(url:"https://ici.firebaseio.com/users")
UpdateRef.observeEventType(.ChildChanged,withBlock: { (snapshot) in
let MomentaryLatitude = snapshot.value["latitude"] as? String
let MomentaryLongitude = snapshot.value["longitude"] as? String
let ID = snapshot.value["ID"] as? String
println("\(MomentaryLatitude)")
var Coordinates = CLLocationCoordinate2D(latitude: MomentaryLatitude as
CLLocationdegrees,longitude: MomentaryLongitude as CLLocationdegrees)
}
最后一行不行,应该用什么呢?
使用doubleValue属性:
let MomentaryLatitude = (snapshot.value["latitude"] as Nsstring).doubleValue let MomentaryLongitude = (snapshot.value["longitude"] as Nsstring).doubleValue