【发布时间】:2015-01-03 16:30:29
【问题描述】:
我正在尝试从我的解析后端查询坐标数组(纬度和经度)。然后将它们用作地图上的注释。虽然一旦我从 parse 中查询过,我不确定如何将坐标转换为 CLLocation。
用于查询的代码:
var usersLocations = [Double]()
override func viewDidLoad() {
super.viewDidLoad()
PFGeoPoint.geoPointForCurrentLocationInBackground { (geopoint: PFGeoPoint!, error: NSError!) -> Void in
var query = PFUser.query()
query.whereKey("location", nearGeoPoint: geopoint, withinMiles: 1)
query.limit = 10
var users = query.findObjects()
for user in users {
self.usersLocations.append(user["location"] as Double)
}
self.currentUsersPoint()
}
}
然后用于尝试将坐标数组放入 CLLocation 的代码。
var latitude:CLLocationDegrees = usersLocation.coordinate.latitude
var longitude:CLLocationDegrees = usersLocation.coordinate.longitude
我知道这有点混乱,我真的只是不确定,因为我对 swift 和编程还是新手,所以很难解决这一切。如果有人可以提供帮助,将不胜感激。
【问题讨论】:
标签: ios xcode swift parse-platform cllocation