Java 如何使用地理点从定义半径内的解析返回图像

Java 如何使用地理点从定义半径内的解析返回图像,java,android,parse-platform,android-location,Java,Android,Parse Platform,Android Location,我正在构建一个应用程序,根据用户当前的位置,使用地理点从解析云返回图像 我需要有关如何获取用户当前位置的帮助,并根据用户定义的半径,从ParseCloud查询图像 protected Void doInBackground(Void... params) { // Create the array worldpopulationlist = new ArrayList<PlaceFilter>(); //

我正在构建一个应用程序,根据用户当前的
位置
,使用
地理点
解析
云返回图像

我需要有关如何获取用户当前位置的帮助,并根据用户定义的半径,从
Parse
Cloud查询图像

   protected Void doInBackground(Void... params) {
            // Create the array
            worldpopulationlist = new ArrayList<PlaceFilter>();
            // Locate the class table named "Country" in Parse.com
            ParseQuery<ParseObject> query = new ParseQuery<ParseObject>(
                    "geo_filters");
            // Locate the column named "ranknum" in Parse.com and order list
            // by ascending

            for (ParseObject PlaceName : ob) {
                // Locate images in flag column
                ParseFile image = (ParseFile) PlaceName.get("FilterFile");

                PlaceFilter map = new PlaceFilter();
                map.setPlaceName((String) PlaceName.get("PlaceName"));
                map.setFilterFile(image.getUrl());
                worldpopulationlist.add(map);
            }
            return null;
        }
受保护的Void doInBackground(Void…params){
//创建数组
worldpopulationlist=新建ArrayList();
//在Parse.com中找到名为“Country”的类表
ParseQuery=新的ParseQuery(
“geo_过滤器”);
//在Parse.com和订单列表中找到名为“ranknum”的列
//上升
for(ParseObject地名:ob){
//在标志列中定位图像
ParseFile image=(ParseFile)PlaceName.get(“过滤器文件”);
PlaceFilter映射=新的PlaceFilter();
map.setPlaceName((字符串)PlaceName.get(“PlaceName”);
setFilterFile(image.getUrl());
worldpopulationlist.add(地图);
}
返回null;
}

充满激情地尝试一下

ParseQuery<ParseObject> parseQuery = ParseQuery.getQuery("ImageClassName");
                    Location location = getLastKnownLocation(); //You have to get last known location using LOcationManager or FusedLocation API
                    double latitude = location.getLatitude();
                    double longitude = location.getLongitude();
                    userLocation = new ParseGeoPoint(latitude, longitude);
        parseQuery.whereNear("location", userLocation); //column as location
        parseQuery.whereWithinKilometers("location", userLocation, 5);
        parseQuery.findInBackground(new FindCallback<ParseUser>() {

            @Override
            public void done(List<ParseObject> listImages,
                    ParseException arg1) {
                for(image : listImages){
                    ParseFile parseFile = image.getParseFile("imageColumn");
                        if (parseFile != null) {
                            parseFile.getDataInBackground(new GetDataCallback() {

                                @Override
                                public void done(byte[] data, ParseException e) {
                                    // TODO Auto-generated method stub
                                    if (data != null && e == null) {
                                        Bitmap bitmap = BitmapFactory
                                                .decodeByteArray(data, 0,
                                                        data.length);
                                        myImage.setImageBitmap(bitmap);
                                    } else {
                                        /picture_not_available
                                    }
                                }
                            });
                        } else {
//                                picture_not_available
                        }
                }
                // TODO Auto-generated method stub
                } catch (Exception e) {
                    // TODO: handle exception
                    e.printStackTrace();
                }
            }
        });
ParseQuery ParseQuery=ParseQuery.getQuery(“ImageClassName”);
位置=getLastKnownLocation()//您必须使用LOcationManager或FusedLocation API获取最后一个已知位置
双纬度=location.getLatitude();
double longitude=location.getLongitude();
userLocation=新的地理点(纬度、经度);
parseQuery.whereNear(“位置”,userLocation)//列作为位置
parseQuery.Wherethinkilometer(“位置”,用户位置,5);
findInBackground(新的FindCallback(){
@凌驾
公共作废完成(列表图像,
语法异常(arg1){
用于(图像:listImages){
ParseFile ParseFile=image.getParseFile(“imageColumn”);
if(parseFile!=null){
getDataInBackground(新的GetDataCallback(){
@凌驾
公共无效完成(字节[]数据,解析异常e){
//TODO自动生成的方法存根
if(数据!=null&&e==null){
位图位图=位图工厂
.decodeByteArray(数据,0,
数据(长度);
设置图像位图(位图);
}否则{
/图片不可用
}
}
});
}否则{
//图片不可用
}
}
//TODO自动生成的方法存根
}捕获(例外e){
//TODO:处理异常
e、 printStackTrace();
}
}
});

如何从用户处获取位置?我是否使用过google.gms.location?我还想知道在我的MainActivity中应该在哪里包含上述代码