GeoFlutterFire
GeoFlutterFire copied to clipboard
near places not meet redious
First of all: i created two docs as a test, every doc has difference position with some meters as distance between them.
Gere is set data to Firestore:
Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.best);
final geo = Geoflutterfire();
GeoFirePoint myLocation = geo.point(latitude: position.latitude, longitude:
position.longitude);
FirebaseFirestore.instance.collection( "location").doc('testUser1').update({
'position': myLocation.data,
'latitude':myLocation.latitude,
'longitude': myLocation.longitude,
});
Note: i also created doc for testuser2.
Here i need to see results:
Future getNearDistanceForTest()async{
final geo = Geoflutterfire();
//this my lati-longi as a test user1
GeoFirePoint? center = geo.point(latitude: currentUser.latitude!, longitude:
currentUser.latitude!);
var collectionReference = FirebaseFirestore.instance.collection('location');
double radius = 20; // here i am trying to get only 20km as a distance even though the distance is not more then 10 meters between test user1 and 2
String field = 'position';
await geo.collection(collectionRef: collectionReference)
.within(center: center, radius: radius, field: field, strictMode: true).forEach((element) {
print(element.length); // output 0
});
}
As shown in example the output is 0, but when i increase the radius to a high for example to 500.
So finally the output is 1 , even though the distance is closer than that mush of radius.
i think it needs fixing