title: I am trying to use Geofire to store location and now I want to display the saved coordinates on a map
body: <p><a href="https://i.stack.imgur.com/M51jf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M51jf.png" alt="enter image description here"></a></p>
  
  <p>I am trying to use Geofire to store and display the users that are logged in on a map I am new in android studio as I am able to store location on firebase  using  geofire 
  but I am not able to retrieve the stored location from the firebase </p>
  
  <p>Here is my code</p>
  
  <pre><code>    public class tracking extends FragmentActivity implements 
    GeoQueryEventListener,OnMapReadyCallback, 
  GoogleMap.OnCameraChangeListener{
  private static final GeoLocation INITIAL_CENTER = new GeoLocation(30.7333148, 76.7794179);
  private static final int INITIAL_ZOOM_LEVEL = 14;
  private static final String GEO_FIRE_DB = "https://trace-
  5fa8c.firebaseio.com";
  private static final String GEO_FIRE_REF = GEO_FIRE_DB + "/_geofire";
  private GoogleMap mMap;
  
  
  private GoogleMap map;
  private Circle searchCircle;
  private GeoFire geoFire;
  private GeoQuery geoQuery;
  private Map&lt;String,Marker&gt; markers;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_tracking);
      // Obtain the SupportMapFragment and get notified when the map is ready 
       to be used.
        SupportMapFragment mapFragment = (SupportMapFragment) 
        getSupportFragmentManager()
              .findFragmentById(R.id.map);
        mapFragment.getMapAsync((OnMapReadyCallback) this);
  
  
  
  
      // setup GeoFire
      this.geoFire = new GeoFire(FirebaseDatabase.getInstance().getReferenceFromUrl(GEO_FIRE_REF));
      // radius in km
       this.geoQuery = this.geoFire.queryAtLocation(INITIAL_CENTER, 1);
  
      // setup markers
      this.markers = new HashMap&lt;String, Marker&gt;();
  }
  
  
  @Override
  protected void onStop() {
      super.onStop();
      // remove all event listeners to stop updating in the background
      this.geoQuery.removeAllListeners();
      for (Marker marker: this.markers.values()) {
          marker.remove();
      }
      this.markers.clear();
  }
  
  @Override
  protected void onStart() {
      super.onStart();
      // add an event listener to start updating locations again
      this.geoQuery.addGeoQueryEventListener(this);
  }
  
  @Override
  public void onKeyEntered(String key, GeoLocation location) {
      // Add a new marker to the map
      Marker marker = this.map.addMarker(new MarkerOptions().position(new 
   LatLng(location.latitude, location.longitude)));
       this.markers.put(key, marker);
   }
  
   @Override
   public void onKeyExited(String key) {
      // Remove any old marker
      Marker marker = this.markers.get(key);
      if (marker != null) {
          marker.remove();
          this.markers.remove(key);
      }
  }
  
   @Override
   public void onKeyMoved(String key, GeoLocation location) {
      // Move the marker
      Marker marker = this.markers.get(key);
      if (marker != null) {
          this.animateMarkerTo(marker, location.latitude, location.longitude);
      }
   }
  
   @Override
   public void onGeoQueryReady() {
   }
  
   @Override
   public void onGeoQueryError(DatabaseError error) {
      new AlertDialog.Builder(this)
              .setTitle("Error")
              .setMessage("There was an unexpected error querying GeoFire: " + 
     error.getMessage())
              .setPositiveButton(android.R.string.ok, null)
              .setIcon(android.R.drawable.ic_dialog_alert)
              .show();
     }
  
    // Animation handler for old APIs without animation support
    private void animateMarkerTo(final Marker marker, final double lat, final 
    double lng) {
      final Handler handler = new Handler();
       final long start = SystemClock.uptimeMillis();
      final long DURATION_MS = 3000;
      final Interpolator interpolator = new 
      AccelerateDecelerateInterpolator();
      final LatLng startPosition = marker.getPosition();
      handler.post(new Runnable() {
          @Override
          public void run() {
              float elapsed = SystemClock.uptimeMillis() - start;
              float t = elapsed/DURATION_MS;
              float v = interpolator.getInterpolation(t);
  
              double currentLat = (lat - startPosition.latitude) * v + 
         startPosition.latitude;
              double currentLng = (lng - startPosition.longitude) * v + 
     startPosition.longitude;
              marker.setPosition(new LatLng(currentLat, currentLng));
  
              // if animation is not finished yet, repeat
              if (t &lt; 1) {
                  handler.postDelayed(this, 16);
              }
          }
      });
    }
  
    private double zoomLevelToRadius(double zoomLevel) {
      // Approximation to fit circle into view
      return 16384000/Math.pow(2, zoomLevel);
  }
  
  
  
   @Override
   public void onCameraChange(CameraPosition cameraPosition) {
      LatLng center = cameraPosition.target;
      double radius = zoomLevelToRadius(cameraPosition.zoom);
      this.searchCircle.setCenter(center);
       this.searchCircle.setRadius(radius);
      this.geoQuery.setCenter(new GeoLocation(center.latitude, 
    center.longitude));
      // radius in km
      this.geoQuery.setRadius(radius/1000);
   }
  
    @Override
    public void onMapReady(GoogleMap googleMap) {
    LatLng latLngCenter = new LatLng(INITIAL_CENTER.latitude, 
      INITIAL_CENTER.longitude);
      this.searchCircle = this.map.addCircle(new 
       CircleOptions().center(latLngCenter).radius(1000));
      this.searchCircle.setFillColor(Color.argb(66, 255, 0, 255));
      this.searchCircle.setStrokeColor(Color.argb(66, 0, 0, 0));
      this.map.moveCamera(CameraUpdateFactory.newLatLngZoom(latLngCenter, 
      INITIAL_ZOOM_LEVEL));
      this.map.setOnCameraChangeListener(this);
  }
  }
  </code></pre>
  
  <p>I am not able to retrieve any location coordinates (log and lat)
  please help 
  thanks in advance</p>