I'm running this query, but it only returns the nearby locations when I set the radiusInKm to a very large number (1500).
Anything below that doesn't return anything, even though there are nearby locations.
Stream<Either<Exception, Set<location>>> watchlocations(
UserGeopoint userPosition,
) {
const radiusInKm = 25;
final collectionRef =
_firestore.locationCollection().withConverter<Either<Exception, location>>(
fromFirestore: locationFirestoreHelpers.locationFromFirestore,
toFirestore: (_, __) => {},
);
return GeoCollectionReference<Either<Exception, location>>(collectionRef)
.subscribeWithin(
strictMode: true,
center: GeoFirePoint(
GeoPoint(
userPosition.latitude,
userPosition.longitude,
),
),
radiusInKm: radiusInKm,
field: geo,
geopointFrom: (data) => data.fold(
(l) => throw Exception('Unexpected error'),
(location) => GeoPoint(
location.geo.geopoint.latitude,
location.geo.geopoint.longitude,
),
),
)
.map((snapshot) {
return snapshot.isEmpty
? left(Exception())
: right(
snapshot
.map(
(doc) => doc.data()?.fold(
(l) => null,
(location) => location,
),
)
.whereNotNull()
.toSet(),
);
});
}
I'm running this query, but it only returns the nearby locations when I set the radiusInKm to a very large number (1500).
Anything below that doesn't return anything, even though there are nearby locations.
What could be causing this?