我有以下Firestore数据库。此firestore中的数据是由geofirestore模块https://github.com/geofirestore/geofirestore-js#example-usage添加的。
如何使用geofire查询来查询此firestore以查找字段name="Sex“的位置
请搜索React native的解决方案,谢谢。
发布于 2018-11-06 01:25:03
您可能想看看docs for future queries you may have。然而,对于您想要的查询,它应该相当简单……
// Create query listener
const geoQuery = geoFirestore.query({
center: new firebase.firestore.GeoPoint(10.38, 2.41),
radius: 10.5,
query: (ref) => ref.where('d.details.name', '==', 'Sex')
});
// Then listen for results as they come in
const onKeyEnteredRegistration = geoQuery.on('key_entered', (key, document, distance) => {
console.log(key + ' entered query at ' + document.coordinates.latitude + ',' + document.coordinates.longitude + ' (' + distance + ' km from center)');
});发布于 2020-07-11 07:20:16
上面由@MichaelSolati回答的问题,适用于旧版本的GeoFireStore (2.x.x)。以下是Michael在3.x.x版本上如何进行相同的查询(摘自Github Issue)。
const geocollection: GeoCollectionReference = geofirestore.collection('Users');
const geoQuery = geocollection.near({
center: new firebase.firestore.GeoPoint(50.9235691,10.7218614),
radius: 10.5
}).where('d.details.name', '==', 'Sex');https://stackoverflow.com/questions/53027146
复制相似问题