Skip to content

Instantly share code, notes, and snippets.

@EchoAbstract
Created May 4, 2012 18:32
Show Gist options
  • Save EchoAbstract/2596791 to your computer and use it in GitHub Desktop.
Save EchoAbstract/2596791 to your computer and use it in GitHub Desktop.
Updating our map notes
// Called to update fetch all annotations
- (void)updateMarkers
{
// Get the current limits of the map view
MKCoordinateSpan span = self.worldView.region.span;
// KINVEY: Geo Queries use miles and there are ~69 miles per each latitudeDelta
double distanceInMiles = span.latitudeDelta*69;
CLLocationCoordinate2D mapCenter = self.worldView.centerCoordinate;
// KINVEY: Build a query against the "_geoloc" collection in your backend
// centered at mapCenter, with a distance of distanceInMiles
KCSQuery *q = [KCSQuery queryOnField:@"_geoloc"
usingConditionalsForValues:
kKCSNearSphere,
[NSArray arrayWithObjects:
[NSNumber numberWithFloat:mapCenter.longitude],
[NSNumber numberWithFloat:mapCenter.latitude], nil],
kKCSMaxDistance,
[NSNumber numberWithFloat:distanceInMiles], nil];
// Kinvey: Set the query to our built query
self.mapNotes.query = q;
// Kinvey: Search for our annotations. We'll populate the map in the delegate
[self.mapNotes fetchWithDelegate:self];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment