2

I'm trying to set additional info when setting geoFire object in FB.

Something like:

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.

BanditX
  • 21
  • 3
  • I fixed it with a hack. It just delays the trigger to allow for all of the data to be set first, before retrieving. I would prefer to just set the data all at once though. – BanditX Oct 04 '14 at 11:30

1 Answers1

1

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

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> }
   }
}
iamtankist
  • 3,464
  • 1
  • 19
  • 25
  • 4
    that's gay, so any locations update has to be its own set and you can't just directly make it a child of a pre existing set? – KellysOnTop23 Aug 06 '16 at 01:02