Skip to content

Instantly share code, notes, and snippets.

@henocdz
Last active August 29, 2015 14:09
Show Gist options
  • Select an option

  • Save henocdz/fcf11f182bf7535fe3a0 to your computer and use it in GitHub Desktop.

Select an option

Save henocdz/fcf11f182bf7535fe3a0 to your computer and use it in GitHub Desktop.
Android+Parse GeoSpatial Query
//Assuming that you have "Google Play Services" configured
//protected LocationClient mLocationClient;
//mLocationClient = new LocationClient(this, this, this);
// protected Location mLocation;
float DISTANCE = 0.2;
mLocation = mLocationClient.getLastLocation();
ParseQuery<ParseObject> places = ParseQuery.getQuery("AParseClass");
Log.i(LOG_TAG, mLocation.toString());
places.whereWithinKilometers("location", new ParseGeoPoint(mLocation.getLatitude(), mLocation.getLongitude()), DISTANCE);
places.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> parseObjects, ParseException e) {
for(ParseObject place : parseObjects){
Log.i(LOG_TAG, place.getString("AClassColumn"));
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment