Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Find the Nearest Places based on current lat and long using Parse API(parse.com) in android

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();
like image 677
pujitav Avatar asked Nov 02 '22 20:11

pujitav


1 Answers

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() { ... });
like image 113
Arcayne Avatar answered Nov 14 '22 22:11

Arcayne