2

I found this website How to run a geo "nearby" query with firestore? for find nearby location from my current location when try write swift code to dart like in below it does not retrieve data, please till me what the problem ?

void getDocumentNearBy( double latitude, double longitude , double distance) {

   ~1 mile of lat and lon in degrees
   var lat = 0.0144927536231884;
   var lon = 0.0181818181818182;

var lowerLat = latitude - (lat * distance);
var lowerLon = longitude - (lon * distance);

var greaterLat = latitude + (lat * distance);
var greaterLon = longitude + (lon * distance);

var lesserGeopoint = GeoPoint(lowerLat, lowerLon);
var greaterGeopoint = GeoPoint(greaterLat, greaterLon);


 var docRef = firestore.collection("Coupons");
  var query = docRef.where("Coupons", isGreaterThan: lesserGeopoint).where("Coupons",  isLessThan: greaterGeopoint);



query.snapshots();
builder: (BuildContext context,
AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasData) {
   print(query);
 }else {
       print("there is an error");

  }

  };





void run() {
  Get all locations within 10 miles of Google Headquarters
  getDocumentNearBy(37.422000,  -122.084057,10);
    }
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Ghana
  • 21
  • 1
  • 1
    Please provide a proper code snippet on how you used `query.snapshots()`. What's the widget you are using in the `builder` line? – rickimaru Mar 10 '21 at 01:41
  • I am a beginner in language and do not understood what you said, please can you explain – Ghana Mar 10 '21 at 10:31
  • 1
    As @rickimaru suggested please provide the necessary information required for troubleshooting. The link you have provided has a [video](https://www.youtube.com/watch?v=mx1mMdHBi5Q) that describes the whole process in details. Did you watch the video? – marian.vladoi Mar 10 '21 at 10:34

0 Answers0