3

The radius parameter on GeoflutterFire library has a weird behaviour.

Centering a search on some specific location with known existing results :

setting approximately 1 km radius , there will be some results

setting approximately 1.5 km radius, there will be not results anymore

setting approximately 2km radius, there will be again some results

around and superior to 4 km, most of the first results will be at the extreme of the radius

Does someone manage to create a working case with this library? I would be surprised if this is due to limitation of geohash. I would think more of an error in this library making it pretty useless in a production app if results are not coherent

Can you advise another similar library on Flutter? `

Geoflutterfire geo = Geoflutterfire();
    GeoFirePoint center =
        geo.point(latitude: location.latitude, longitude: location.longitude);

Query collectionQuery =
    FirebaseFirestore.instance.collectionGroup('places');

return geo
    .collection(collectionRef: collectionQuery)
    .within(
        center: center,
        radius: filter.radius!,
        field: 'location',
        strictMode: true)
    .map((snapshots) {}`
LearningPath
  • 612
  • 5
  • 17
  • Hi, did you find a better solution? I am facing a similar problem and read in another question that someone gave up on Flutter for this and switched to Parse Server: https://stackoverflow.com/questions/56674470/flutter-firestore-geo-query – Big_Chair Mar 31 '23 at 11:32

1 Answers1

0

I think the answer lays there, which makes me wonder how other app manage to have a proper location filtration whatever the radius. Do they use library without geohash? The current limitation makes the library useless per my point of view

Usage of strictMode

It's advisable to use strictMode = false for smaller radius to make use of documents from neighbouring hashes as well.

As the radius increases to a large number, the neighbouring hash precisions fetch documents which would be considerably far from the radius bounds, hence its advisable to use strictMode = true for larger radius.

Note: filtering for strictMode happens on client side, hence filtering at larger radius is at the expense of making unnecessary document reads.

LearningPath
  • 612
  • 5
  • 17