gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 18:50:42 24 4
gpt4 key购买 nike

代码如下。我在那里看到了所有以前提出的问题,他们犯了错误的引用或未使用 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

关于android - 尽管不断调用 onGeoQueryReady,但永远不会触发 Geofire onKeyEntered,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50999767/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com