如何在Geofire

时间:2017-04-03 03:52:54

标签: android firebase firebase-realtime-database geofire

enter image description here

  

这是我用来输入值的代码

   geoFire.setLocation("firebase-hq", new GeoLocation(37.7853889, -122.4056973), new GeoFire.CompletionListener() {
        @Override
        public void onComplete(String key, DatabaseError error) {
            if (error != null) {
                System.err.println("There was an error saving the location to GeoFire: " + error);
            } else {
                System.out.println("Location saved on server successfully!");
            }
        }

    });
  

这是我用来检索值的代码

 geoFire.getLocation("firebase-hq", new LocationCallback() {
            @Override
            public void onLocationResult(String key, GeoLocation location) {
                if (location != null) {
                    Log.e("longitude",String.valueOf(location.longitude));
                    Log.e("latitude",String.valueOf(location.latitude));

                   // System.out.println(String.format("The location for key %s is [%f,%f]", key, location.latitude, location.longitude));
                } else {
                    Log.e("error","There is no location for key %s in GeoFire");

                }
            }
  

我的问题是我需要输入多个位置值并将它们作为列表或Json对象检索。如何为此更新当前代码。提前谢谢。

0 个答案:

没有答案