Closed kingtross88 closed 6 years ago
i just saw another post that had the answer. Sorry to bother you. i'm closing this out.
@kingtross88 could you tell me which post you saw the answer/solution in? If my docs aren't clear I should probably update them based on what works!
I saw it in the below post.
https://github.com/MichaelSolati/geofirestore/issues/3
I had to put use import { GeoFirestore } from "geofirestore";. This is the only way I didn't get an error. I'm adding info to my firestore database now. I didn't pull the info as of yet but I'll let you know if I'm able to figure that out. Other than that I think your documentation is pretty well detailed.
Thank you for responding!
I am writing a goodle cloud function which uses GeoFirestore.
The init code looks like this
const admin = require('firebase-admin'); const functions = require('firebase-functions'); const GeoFireStore = require('geofirestore'); //Initialize Firebase admin.initializeApp(functions.config().firebase); const db = admin.firestore();
Have written a https trigger that looks like the following
exports.helloWorldOK = functions.https.onRequest((request, response) => { const userQRObject = db.collection('UserQRObject'); var ref = new GeoFireStore(userQRObject); response.status(200).json({data:'geoFirestore'}); });
I get the error GeoFireStore is not a constructor. Please help me resolve.
@rajeshgadepalli => https://stackoverflow.com/a/53842723/5076023
thank you @MichaelSolati , it worked. I could move to the next level but stuck here.
My query looks like this
const geoQuery = geoFirestore.query({ center: new firebase.firestore.GeoPoint(17.500362, 78.587374), radius: 1 //, // query: (ref) => ref.where('d.count', '==', 1) });
How do I iterate the results now ?
@rajeshgadepalli you'll have to store the results into an array and when the ready
listener fires saying the query is done you can sort and order the results.
@MichaelSolati this is what i have done basing on your suggestion. Is this a proper implementation to get the nearby locations ?
const geoQuery = geoFirestore.query({ center: new firebase.firestore.GeoPoint(17.500362, 78.587374), radius: 1 }); geoQuery.on('ready', () => { console.log('GeoFirestoreQuery has loaded and fired all other events for initial data'); var locations = geoQuery._locationsTracked; var keys = []; locations.forEach(function (locationMap, key) { if (typeof locationMap !== 'undefined' && locationMap.isInQuery) { console.log('key', key); keys.push(locationMap); } }); response.status(200).json(keys); });
@rajeshgadepalli the formatting is difficult to read, and this isn't really an issue with the library. I'd advise possibly asking this question on Stack Overflow. (I check there too)
@MichaelSolati Have posted the question
https://stackoverflow.com/questions/53983550/fetch-nearby-geo-results-using-geofirestore
I'm able to get this to work with implementing this with geofire. I'd like to use Geofirestore because I'm using firestore within my application.(I figured it would be a better choice).
This works for react native. const geofire = require('geofire');
I keep getting 'geofirestore is not a constructor' error message. Can you assist me with getting this to work in react native?