Querying an array of GeoPoints using Parse

353 views Asked by At

I have an item that has multiple locations. I currently store an array of GeoPoints as a field on "item" to keep track of these locations. I want to see if one of the geopoints in the array lies within x amount of miles from a location and I want to return that item, along with any other items that contain a point within x miles.

 PFQuery *query = [PFQuery queryWithClassName:@"item"];
[query whereKey:@"locations" nearGeoPoint:pfPoint withinMiles:miles];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    NSLog(@"returned");
}];

I get the error "error=$nearSphere: only works on gepoints fields", which makes sense. The field must be of type GeoPoint. Can I do this from the Parse iOS SDK?

0

There are 0 answers