let geolocationRef = db.ref("geolocations/");
var lat = data.lat;
var lon = data.lon;
var area = data.area;
var reqFacilities = data.facilities || [];
var geoFire = new GeoFire(geolocationRef);
var geoQuery = geoFire.query({
center: [parseFloat(lat), parseFloat(lon)],
radius: parseFloat(area) // the minimum radius that will return
});
var hotelDataArray = [];
geoQuery.on("key_entered", function(key, location, distance) {
let adsRef = db.ref("ads/" + key);
adsRef.on("value", (snapshot) => {
if (snapshot.val().facilities !== undefined) {
let facilityArray = Object.keys(snapshot.val().facilities);
if (reqFacilities.every(val => facilityArray.includes(val))) {
console.log("Pushed")
hotelDataArray.push({key: key, distance: distance.toFixed(2), data :snapshot.val()});
}
}
})
});
console.log(hotelDataArray,"last")
返回{hotelDataArray};
});
这是我的地火代码,可让您使用指定设施获得最近的酒店 但它不能正确返回数据 控制台打印如
[]最后
按
返回零值
我需要对配备设施的酒店进行分类,如何正确对其进行分类 请帮助我