2017-07-12 1 views
0

this is how location is saved in firebase私はfirebase

でgeofireを使用して場所を挿入している私は今、私はマーカーを持つ単一のGoogleマップの活動のすべての場所を取得したいアンドロイドスタジオでの活動の一つからfirebaseでgeofireを使用して場所を挿入しました。 マップアクティビティを作成しましたが、firebaseからロケーションを取得する方法がわかりません。

私はこの問題に取り組んでいます。いくつかのソースコード。ここで

は場所を送信するための私のコードは、あなたが

 GeoFire geoFire = new GeoFire(ref); 

は今以内地理firelocationを盗んgeofireオブジェクトより

DatabaseReference ref = FirebaseDatabase.getInstance().getReference("/path/"); 

最初のデータの参照を作成する必要が

GeoFire geoFire = new 
GeoFire(databaseReference.child("Location").child(user.getUid())); 
      geoFire.setLocation("location", new 
GeoLocation(location.getLatitude(), location.getLongitude()), new 
GeoFire.CompletionListener() { 
       @Override 
       public void onComplete(String key, DatabaseError error) { 
        if (error != null) { 
         Toast.makeText(gpdfuel.this, "There was an error 
saving the location to GeoFire: " + error, Toast.LENGTH_LONG).show(); 
        } else { 
         Toast.makeText(gpdfuel.this, "Location saved on server 
successfully!", Toast.LENGTH_LONG).show(); 

        } 
       } 
      }); 

答えて

0

firebaseすることですこのような特定の範囲

GeoQuery geoQuery = geoFire.queryAtLocation(new GeoLocation(lat, long), radius); 
    geoQuery.addGeoQueryEventListener(new GeoQueryEventListener() { 
     @Override 
     public void onKeyEntered(String key, GeoLocation location) { 
      Log.d(Const.TAG,String.format("Key %s entered the search area at [%f,%f]", key, location.latitude, location.longitude)); 
     } 

     @Override 
     public void onKeyExited(String key) { 
      Log.d(Const.TAG,String.format("Key %s is no longer in the search area", key)); 
     } 

     @Override 
     public void onKeyMoved(String key, GeoLocation location) { 
      Log.d(Const.TAG,String.format("Key %s moved within the search area to [%f,%f]", key, location.latitude, location.longitude)); 
     } 

     @Override 
     public void onGeoQueryReady() { 
      Log.d(Const.TAG,"All initial data has been loaded and events have been fired!"); 
     } 

     @Override 
     public void onGeoQueryError(DatabaseError error) { 
      Log.d(Const.TAG,"There was an error with this query: " + error); 
     } 
    }); 
関連する問題