尽管不断调用 onGeoQueryReady,但永远不会触发 Geofire onKeyEntered

Geofire onKeyEntered is never triggered though onGeoQueryReady is called endlessly

代码如下。我在那里看到了所有以前提出的问题,他们犯了错误的错误参考或未使用 Geofire.set 方法设置 geofire。请帮助

  private void georadius(final LatLng pickup)
    {
        //geo
        DatabaseReference r2=root.child("Active_Drivers");
        GeoFire mG=new GeoFire(r2);

        GeoQuery m=mG.queryAtLocation(new GeoLocation(pickup.latitude,pickup.longitude),radius);
        m.removeAllListeners();

        m.addGeoQueryEventListener(new GeoQueryEventListener() {
            @Override
            public void onKeyEntered(String key, GeoLocation location) {
               if (driverfound==false) {
                   driverfound = true;
                   driverid = key;
                   driverlocation = new LatLng(location.latitude, location.longitude);
               }
            }

            @Override
            public void onKeyExited(String key) {

            }

            @Override
            public void onKeyMoved(String key, GeoLocation location) {

            }

            @Override
            public void onGeoQueryReady() {

                if (driverfound==false)
                {
                    radius++;
                    georadius(pickup);

                }

            }

            @Override
            public void onGeoQueryError(DatabaseError error) {

            }
        });
    }

我的JSON:

{
  "Active_Drivers" : {
    "LgEnzsB4y3g0tQZEnIMJRFnnREU2" : {
      "location" : {
        ".priority" : "ttqwsbkq5d",
        "g" : "ttqwsbkq5d",
        "l" : [ 30.6762423, 76.85536 ]
      }
    }
  },
  "Customer Requests" : {
    "nCz2Rlk2SafeTXWarBs4T8EiIdm2" : {
      "location" : {
        ".priority" : "ttqwsbu1fy",
        "g" : "ttqwsbu1fy",
        "l" : [ 30.6782832, 76.8549792 ]
      }
    }

您的数据结构看起来与 this 示例不同:

{
  "fish1" : {
    "g" : "pns0h0mf2u",
    "l" : [ -53.435719, 140.808716 ]
  },
  "fish2" : {
    "g" : "u417k3dwub",
    "l" : [ 56.83069, 1.94822 ]
  },
  "fish3" : {
    "g" : "8m3rz3s480",
    "l" : [ 30.902225, -166.66809 ]
  }
}

每个 child 你还有一个额外的 location 级别。我很确定 Geofire 会直接在每个 child.

下寻找 .priorityg