Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

near places not meet redious #180

Open
jack84156 opened this issue Feb 28, 2022 · 0 comments
Open

near places not meet redious #180

jack84156 opened this issue Feb 28, 2022 · 0 comments

Comments

@jack84156
Copy link

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

@jack84156 jack84156 changed the title near places no meet redious near places not meet redious Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant