我创建了此方法用于查找附近的用户,如果此方法称为“在用户附近,则找到附近的用户”,然后增加并再次调用“ self”,但是我想将用户限制为5 km,问题是当我将限制设置为可用时用户没有显示.. 此代码没有设置限制,可以完美地运行
require('./logging')();
这是我设置限制的另一种方法
int radius=0; //radius=0
String driverId; //driverId=null
boolean driverFound=false;
//This Method Find Near Dear
void FindDriver(final LatLng theLocation){
DatabaseReference mRef= FirebaseDatabase.getInstance().getReference(DriverType);
GeoFire geoFire=new GeoFire(mRef);
GeoQuery query=geoFire.queryAtLocation(new GeoLocation(theLocation.latitude,theLocation.latitude),radius);
query.removeAllListeners();
query.addGeoQueryEventListener(new GeoQueryEventListener() {
//When this method find driver call antoher method and finish this activity
@Override
public void onKeyEntered(String key, GeoLocation location){
if(!driverFound){
driverFound=true;
driverId=key;
SetDriver(driverId)}
@Override
public void onKeyExited(String key) {}
@Override
public void onKeyMoved(String key, GeoLocation location) {}
@Override
public void onGeoQueryReady() {
if(!driverFound){
radius++;
FindDriver(theLocation); //Method Call it self and increase the radius if driver still not found
}
}
@Override
public void onGeoQueryError(DatabaseError error) {
}
});
}
}
可能在那里,我使用了另一种逻辑,但是我不知道如何,请帮助我, 在此先感谢:)