Reputation: 494
I created a query in express to extract my data this is my express function for endpoint:
app.get('/locatii', (req, res) => {
const geofirestore = new GeoFirestore(db);
const geocollection = geofirestore.collection('locatii2');
const query = geocollection.near({
center: new firebase.firestore.GeoPoint(45.831922, 27.431149),
radius: 3000
});
query.get().then(snap => {
console.log(snap.docs())
let places = [];
snap.forEach(doc => {
places.push(doc.data());
console.log(doc.data())
});
res.json(places);
})
.catch(err => res.send(err));
});
below it's my firesore structure:
When I acces my endpoint it don't shows in console data or in postman.I don't know what I missed.Thank you!
Upvotes: 0
Views: 135
Reputation: 599351
Your data structure doesn't seem to have a geohash in it. Having a geohash in each document is required for being able to query those documents by their location.
From the example app that come with GeoFirestoreJS, it seems that you can get the geohash with something like:
location.lat = ...
location.lng = ...
const hash = geokit.Geokit.hash(location);
And then set it into your Firestore document with something like:
documentRef.update(hash);
Upvotes: 1