Closed shekhars-realm closed 5 years ago
Can I see your query? If it isn't a geoquery then distance will be null.
sure.
geofirestore.collection('events').near({ center: new admin.firestore.GeoPoint(49.444231, 7.699167), radius: 1.5 }).get().then(data => { console.log('data: ',data.docs); })
the data structure is same as suggested in the docs.
The distance should work just fine, I created a sample stackblitz example showing how to access distance here => https://stackblitz.com/edit/geofirestore-distance
I'd advise starting to look at line 32, and if your code looks like that and still doesn't work then it is likely an issue with how the data is stored. Geofirestore works with data added to a collection by geofirestore, so it's good to be familiar with what that looks like.
Since I can not replicate this, I'm closing the issue, however if you can provide sample code and a screenshot example of a document in a collection we can go from there!
PS, the distance will be null if the l
field is not a proper GeoPoint. While you never see the g
or l
, only the content of the d
, geofirestore needs them to work properly.
Hey, sorry for the later reply.
I guess there is some problem in the way I am storing the data:
I am using l for sorting the data, not locationString
For me distance returns as null if I didn't set radius property
here is the return object:
[ { exists: true, id: 'VXgVXlvwLVXAFKDifcOKq', data: [Function: data], distance: null } ]
Any possible reasons!