Closed WieFel closed 2 years ago
I found that is required to use geohash, try it!
@bichoalexis can you give an example? I don't get what you mean exactly...
Just tried
.within(
center: point.data, // added .data
radius: radius,
field: "position",
);
but it gives a type error, because point.data
is no GeoFirePoint
.
I mean, in your Firestore database, when you create a new location, add geohash with geopoints, not just geopoints, then everything will work. By the way, if your are using the latest Firestore version with flutter web, I recommend you to change the dependency to geoflutterfire2. It has more support, this package looks abandoned. :)
@bichoalexis thanks, I already use geoflutterfire2
now.
But still I don't get it to work. My document looks like this:
var radius = 100.0;
var point = geo.point(latitude: 0.0, longitude: 0.0);
return geo.collection(collectionRef: collection).within(
center: point,
radius: radius,
field: "position",
);
Whether I use position
or position_hash
as field
, it doesn't work either...
Try to write manually this in your latest document:
@bichoalexis thank you so much, now I finally got it working! What I was missing was the correct data structure within firestore.
geo.collection(collectionRef: collection).within(
...
field: "point",
);
Hi,
I am always getting empty results when querying my collection for close documents within 1km. For being sure, i just created a new collection in my firestore called
test
, with one document which has some hardcoded coordinates.In my flutter code, i then query documents in a radius of 1km of that same pair of lat/lon, but I still get an empty result.
(where
firebaseState.test
is defined asget test => _firestore.collection("test");
Running Flutter
3.0.2
and Dart2.17.3
, with package versionsgeoflutterfire: ^3.0.2
andcloud_firestore: ^3.1.17
.Any hints on what I could be doing wrong?