GeoFire结构与文档不匹配

时间:2016-03-01 21:46:49

标签: jquery firebase rsvp.js geofire

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的示例和文档中非常普遍)

以下是examples

我希望我很清楚,否则请告诉我。

1 个答案:

答案 0 :(得分:0)

问题是早期版本的GeoFire以不同的格式存储数据,问题是没有任何参考......在任何地方。