MichaelSolati / geofirestore-js

Location-based querying and filtering using Firebase Firestore.
https://geofirestore.com
MIT License
505 stars 58 forks source link

Adding document parameters breaks the model #197

Closed jaredgibb closed 3 years ago

jaredgibb commented 4 years ago

[REQUIRED] Describe your environment

I forked the viewers repository i added my own firebase I created my own collection of documents I added 2 parameters 'city' and 'interestingFact' the documents enter the collection just fine

Describe the bug

only my location appears. none of the markers I add appear

Steps to Reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll to '....'
  4. See error

Relevant Code

jaredgibb.github.io/viewers/ ^^^^^ all code can be found here ^^^^^^

function getInFirestore(location, city, interestingFact) {
  location.lat = Number(location.lat.toFixed(1));
  location.lng = Number(location.lng.toFixed(1));
  const hash = Geokit.hash(location);

  geoCollectionRef.doc(hash).get().then((snapshot) => {
    let data = snapshot.data();
    if (!data) {
      data = {
        city: city,
        interestingFact: interestingFact,
        coordinates: new firebase.firestore.GeoPoint(location.lat, location.lng)
      };
      console.log('Provided key is not in Firestore, adding document: ', JSON.stringify(data));
      createInFirestore(hash, data);
    } else {

      console.log('Provided key is in Firestore, updating document: ', JSON.stringify(data));
      updateInFirestore(hash, data);
    }
  }, (error) => {
    console.log('Error: ' + error);
  });
}

the original document that appears on the screen

Screen Shot 2020-10-27 at 2 41 55 PM

this image demonstrates that the documents are created.

Screen Shot 2020-10-27 at 2 42 01 PM

it seems like the code is only recieving 1 document. i'm so new to JS that i am lost. any help will be appreciated!

Screen Shot 2020-10-27 at 2 44 13 PM