I have an android app which shows user's markers in nearby location to mine with specified radius. For example: I set radius on 1 km, and I would like to retrieve all users which are in this radius. At now, on a map I have markers but I would like to also display users. How could I do that? I can not see any specific documentation to allow get users from radius in GeoFire. Using Map, I can count amount of markers.
I have in a database user child also, which display name, nick etc. Should I use this part to display users' nick in this radius?
Here is my code:
ref_red = FirebaseDatabase.getInstance().getReference("geofire/red_marker");
geoFireRed = new GeoFire(ref_red);
geoQuery = geoFireRed.queryAtLocation(new GeoLocation(lat, lng), km);
geoQuery.addGeoQueryEventListener(new GeoQueryEventListener() {
@Override
public void onKeyEntered(String key, GeoLocation location) {
geoItems.setText("Somebody is here. " + String.valueOf(markers.size()));
Marker marker = mGoogleMap.addMarker(new MarkerOptions().position(new LatLng(location.latitude, location.longitude))
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
markers.put(key, marker);
tvDetected.setText("Object detected." + String.valueOf(markers.size()));
}
@Override
public void onKeyExited(String key) {
geoItems.setText("Nobody is here. " + String.valueOf(markers.size()));
Marker marker = markers.get(key);
if (marker != null) {
marker.remove();
markers.remove(key);
}
}
@Override
public void onKeyMoved(String key, GeoLocation location) {
Marker marker = markers.get(key);
if (marker != null) {
marker.remove();
markers.remove(key);
}
}
@Override
public void onGeoQueryReady() {
}
@Override
public void onGeoQueryError(DatabaseError error) {
}
});
And here is my part of geofire database:
Could someone help me to resolve this problem?