GeoFire 正在使用未记录的结构保存数据。我怎样才能像官方示例一样保存它。我没有遵循任何特定的教程或指南,但我的工作主要基于这些示例。
我已经能够复制这个问题:
JS:
var ref = new Firebase("https://skgz3dfvs9.firebaseio-demo.com");
var geoFire = new GeoFire(ref.child("_geofire"));
geoFire.set("ADb3b3j2"+parseInt(Math.random(1000)*10000), [20.573771400000002, -100.35827]).then(function() {
document.getElementById("result").innerHTML = "Provided key has been added to GeoFire";
}, function(error) {
document.getElementById("result").innerHTML = "Error: " + error;
});
HTML
<div id="result"></div>
https://jsfiddle.net/johnhparkerg/c0852c6s/1/
生成如下所示的 JSON:
{
"_geofire":{
"i":{
"9g8th336fu:ADb3b3j2":true,
"9g8th336fu:ADb3b3j21770":true,
"9g8th336fu:ADb3b3j23390":true,
"9g8th336fu:ADb3b3j24122":true,
"9g8th336fu:ADb3b3j25036":true,
"9g8th336fu:ADb3b3j27393":true,
"9g8th336fu:ADb3b3j28182":true,
"9g8th336fu:ADb3b3j28276":true,
"9g8th336fu:ADb3b3j29206":true,
"9g8th336fu:ADb3b3j29674":true
},
"l":{
"ADb3b3j2":[
20.573771400000002,
-100.35827
],
"ADb3b3j21770":[
20.573771400000002,
-100.35827
],
"ADb3b3j23390":[
20.573771400000002,
-100.35827
],
"ADb3b3j24122":[
20.573771400000002,
-100.35827
],
"ADb3b3j25036":[
20.573771400000002,
-100.35827
],
"ADb3b3j27393":[
20.573771400000002,
-100.35827
],
"ADb3b3j28182":[
20.573771400000002,
-100.35827
],
"ADb3b3j28276":[
20.573771400000002,
-100.35827
],
"ADb3b3j29206":[
20.573771400000002,
-100.35827
],
"ADb3b3j29674":[
20.573771400000002,
-100.35827
]
}
}
}
https://skgz3dfvs9.firebaseio-demo.com/
结果应如下所示:
{
"fish1":{
"g":"pns0h0mf2u",
"l":[
-53.435719,
140.808716
]
},
"fish2":{
"g":"u417k3dwub",
"l":[
56.83069,
1.94822
]
},
"fish3":{
"g":"8m3rz3s480",
"l":[
30.902225,
-166.66809
]
}
}
(这种结构在有关 firebase 和 geofire 的示例和文档中普遍存在)
下面是例子。
我希望我足够清楚,否则请告诉我。