0

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.

JohnParkerG
  • 65
  • 1
  • 10
  • instead of linking to a dashboard, include the (minimal) JSON into your question (as text). Links rot, as the image in the question you linked to shows. Your jsfiddle is empty btw. – Frank van Puffelen Mar 02 '16 at 07:08
  • Aside from that, I don't understand what you're asking. Why is the structure wrong according to you? How did you write the structure? The fact that it is different from a tutorial is irrelevant, unless you're trying to follow that tutorial. But if that is the case, show the exact minimal code that you used. Without an [mcve](http://stackoverflow.com/help/mcve) it's difficult to help. – Frank van Puffelen Mar 02 '16 at 07:12
  • I've edited to make it clearer, please be so kind as to give me your opinion about the clarity of the question and if it is possible, some guidance. – JohnParkerG Mar 02 '16 at 16:26

1 Answers1

0

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.

JohnParkerG
  • 65
  • 1
  • 10