问题描述
在FB中设置geoFire对象时,我正在尝试设置其他信息.
I'm trying to set additional info when setting geoFire object in FB.
类似的东西:
geoFire.set(uniqueId, [latitude, longitude],{'message': message, 'iconUrl': iconURL, lastUpdate: Firebase.ServerValue.TIMESTAMP}).then(function () {
//some stuff
};
我可以这样做,并且大多数情况下都有效(取决于数据库往返时间):
I can do it like this and it mostly works (depends on db roundtrip time):
geoFire.set(uniqueId, [latitude, longitude],).then(function () {
firebaseRef.child(uniqueId).update({'message': message, 'iconUrl': iconURL, lastUpdate: Firebase.ServerValue.TIMESTAMP});
})
但是我的侦听器触发得太快并且无法捕获所有数据,因此呈现时没有图标路径.
but my listener triggers too fast and doesn't capture all the data so it renders without icon path.
推荐答案
我遇到了同样的问题,不想通过变通办法解决此问题,特别是引入了延迟,因此不断挖掘并发现了这个问题: https://github.com/firebase/geofire-js/issues/40
I had the same problem, didn't want to solve this with a workaround, especially by introducing the delay so kept digging and found this: https://github.com/firebase/geofire-js/issues/40
这基本上意味着我们需要重组应用程序,其中一个集合专用于GeoFire信息,另一个集合使用相同的密钥来存储附加信息.来自GitHub的示例.
This basically means we need to restructure the application, where one collection is dedicated to the GeoFire information, another uses the same key to store attached information. Example from the GitHub.
{
geofire: {
"-J9aZZl94Sx6h": { "g": <geohash>, "l": {} }
"-Jhacf97x4S3h": { "g": <geohash>, "l": {} },
...
},
"locations": {
"-J9aZZl94Sx6h": { <location-data> },
"-Jhacf97x4S3h": { <location-data> }
}
}
这篇关于在GeoFire Firebase中进行设置时要添加其他子级吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!