5

我想使用解析 API 找出最近的地方。当我输入城市名称时,我必须根据当前的纬度和经度找到所有最近的地方。我的关键字将在解析数据库中。请让我知道我该怎么做it.Here 是我尝试过的示例代码

//for finding the nearest places
    ParseGeoPoint point = new ParseGeoPoint(17.5, -54.2); 
    ParseObject object = new ParseObject("Places");
    object.put("hyderabad", point); 
    object.save();
4

1 回答 1

2

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() { ... });
于 2013-06-14T13:21:41.380 回答