Swift [错误]:$nearSphere:仅适用于gepoints字段(代码:102,版本:1.6.2)

Swift [错误]:$nearSphere:仅适用于gepoints字段(代码:102,版本:1.6.2),swift,location,Swift,Location,我正在尝试使用query并接收我在解析时保存的所有数据。基本上,当用户更改其位置时,他可以从parse接收不同的数据。有点像任何一堵墙。但是我一直收到这个错误:[error]:$nearSphere:仅适用于gepoints字段(代码:102,版本:1.6.2) 任何帮助都将不胜感激 class ViewController: UIViewController, CLLocationManagerDelegate { var usersAltitude : NSNumber!

我正在尝试使用query并接收我在解析时保存的所有数据。基本上,当用户更改其位置时,他可以从parse接收不同的数据。有点像任何一堵墙。但是我一直收到这个错误:[error]:$nearSphere:仅适用于gepoints字段(代码:102,版本:1.6.2) 任何帮助都将不胜感激

class ViewController: UIViewController, CLLocationManagerDelegate 
{

    var usersAltitude : NSNumber!
    var usersLongitude : NSNumber!
    let locationManager = CLLocationManager()
    var photoPoint : PFGeoPoint!
    var usersGeoPoint : PFGeoPoint!
    @IBOutlet var imageView: UIImageView!
    var currentLocation : CLLocationCoordinate2D?



override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    //uploadingPhoto()
    loadImages()


    self.locationManager.delegate = self
    self.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
    self.locationManager.distanceFilter = kCLLocationAccuracyBest
    self.locationManager.requestWhenInUseAuthorization()
    self.locationManager.startUpdatingLocation()



}

func loadImages(){

    var query = PFQuery(className: "photos")

            query.whereKey("myImage", nearGeoPoint: usersGeoPoint   , withinKilometers: 1)
            query.findObjectsInBackgroundWithBlock({
                (objects: [AnyObject]!, error: NSError!) -> Void in

                if (error == nil){

                    let imageObjects = objects as [PFObject]
                    for object in objects {

                        let photoToView = object["myImage"] as PFFile

                        photoToView.getDataInBackgroundWithBlock({
                            (imageData: NSData!, error: NSError!) -> Void in
                            if (error == nil){


                                self.imageView.image = UIImage(data:imageData)
                                println("success")


                            }else {

                                println("error")
                            }
                        })
                    }
                }
            })
    }






override func viewDidDisappear(animated: Bool) {
    self.locationManager.stopUpdatingLocation()
}




func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
    CLGeocoder().reverseGeocodeLocation(manager.location, completionHandler: {(placemarks, error)-> Void in

        if (error != nil) {

            println("Error:" + error.localizedDescription)
            return
        }

        if placemarks.count > 0 {
            let pm = placemarks [0] as CLPlacemark
            let addressDictionary = placemarks
            self.displayLocationInfo(pm)
        }else {
            println("Error with date")
        }
    })
}



override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
    return UIInterfaceOrientation.Portrait
}

func displayLocationInfo(placemark: CLPlacemark){

    usersAltitude = placemark.location.coordinate.latitude
    usersLongitude = placemark.location.coordinate.longitude
     usersGeoPoint = PFGeoPoint(latitude: placemark.location.coordinate.latitude, longitude: placemark.location.coordinate.longitude)

    self.locationManager.stopUpdatingLocation()
}



override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}




func locationManager(manager: CLLocationManager!, didFailWithError error: NSError!) {
    println("Error:" + error.localizedDescription)
}
}

我也有同样的问题,对我来说,这是因为我有一个字符串“name”。它必须是您正在查询的一个点。因此,在代码中,您需要在parse中将“myImage”替换为包含纬度和经度坐标的列。你现在可能已经明白了,但我说过我会回答的,以防这对其他人有帮助

query.whereKey("myImage", nearGeoPoint: usersGeoPoint   , withinKilometers: 1)
        query.findObjectsInBackgroundWithBlock({