Firebase Cloud功能中的Geofire查询 [英] Geofire Query in Firebase Cloud Function
本文介绍了Firebase Cloud功能中的Geofire查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对不起,对于英语,我怀疑是否有可能在Firebase Cloud Func中使用其各自的key_enter和key_exited进行查询geofire,以便维护从我的位置?中提取的地理位置的列表.几十万.考虑到所有这些情况都是在用户在节点Firebase实时数据库中更新其地理位置时发生的,因此,成千上万的列表减少到用户位置附近的几分之一
Sorry for my english, I have a doubt it is possible to make a query geofire in Firebase Cloud Func, with their respective key_enter and key_exited, in order to maintain a list of the geographic points near my position ?, extracted from a few hundred thousand. Taking into account that all this happens when the user updates its geolocation in a node firebase realtime database, and this list of hundreds of thousands is reduced to a few near the position of the user
推荐答案
这是没有模块的样子
let functions = require('firebase-functions');
let GeoFire = require('geofire');
exports.testLocation = functions.database.ref('/items/{item}').onWrite(event => {
let data = event.data.val();
console.log(data);
console.log(event.params.item);
if (data.location && data.location.coords) {
console.log('Update GeoFire');
let ref = event.data.adminRef.parent.parent.child('/items_locations'));
let key = event.params.test;
let location = [data.location.coords.latitude, data.location.coords.longitude]);
let geoFire = new GeoFire(ref);
geoFire.set(key, location).then(() => {
console.log('Update succesfull');
}).catch(error => {
console.log(error);
});
}
}
这篇关于Firebase Cloud功能中的Geofire查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文