Reputation: 528
I want to find out the nearest places using parse API.When i enter a city name i have to find all the nearest places based on current latitude and longitude.My keywords will be there in parse database.Please let me know how can i do it.Here is the sample code which i have tried
//for finding the nearest places
ParseGeoPoint point = new ParseGeoPoint(17.5, -54.2);
ParseObject object = new ParseObject("Places");
object.put("hyderabad", point);
object.save();
Upvotes: 5
Views: 2855
Reputation: 1186
Did you try whereWithinKilometers, whereWithinMiles or whereWithinRadians
Check on the ParseQuery in the right menu.
You code will look like something like:
ParseGeoPoint userLocation = (ParseGeoPoint) userObject.get("location");
ParseQuery query = new ParseQuery("PlaceObject");
query.whereWithinKilometers("location", userLocation);
query.findInBackground(new FindCallback() { ... });
Upvotes: 2