GeoFire structure doesn't match documentation

207 Views Asked by At

GeoFire is saving data using an undocumented structure. How can I get it to save like the official examples. I haven't followed any particular tutorial or guide, but I've based my work heavily on these examples.

I've been able to replicate the issue:

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/

Results in a JSON that looks like this:

{  
   "_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/

When the result should look like this:

{  
   "fish1":{  
      "g":"pns0h0mf2u",
      "l":[  
         -53.435719,
         140.808716
      ]
   },
   "fish2":{  
      "g":"u417k3dwub",
      "l":[  
         56.83069,
         1.94822
      ]
   },
   "fish3":{  
      "g":"8m3rz3s480",
      "l":[  
         30.902225,
         -166.66809
      ]
   }
}

(This structure is pervasive across examples and documentation regarding firebase and geofire)

Here are the examples.

I hope I was clear enough, otherwise let me know.

1

There are 1 best solutions below

0
JohnParkerG On

The problem was that an earlier version of GeoFire stored data in a different format, problem was that there was no reference to that... anywhere.