Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从Firebase按纬度和经度显示附近用户的颤振_Firebase_Flutter_Google Cloud Firestore_Stream Builder_Geofirestore - Fatal编程技术网

从Firebase按纬度和经度显示附近用户的颤振

从Firebase按纬度和经度显示附近用户的颤振,firebase,flutter,google-cloud-firestore,stream-builder,geofirestore,Firebase,Flutter,Google Cloud Firestore,Stream Builder,Geofirestore,我有两个应用程序正在连接在一起,它们的工作原理如下:它类似于食品配送,我有一个餐厅应用程序,它将添加餐厅位置,我将通过纬度和经度在我的Firebase餐厅收藏中存储此位置。在另一个应用程序“eater”应用程序中,我想显示Firestore附近的餐厅文档(现在文档包括名称、图像和描述) 使用“食客”应用程序,我已经可以存储他们的当前位置。我唯一想做的就是展示附近的餐馆 这是我的ShowNearByCompanys()函数 Stream showNearbyCompanies() async* {

我有两个应用程序正在连接在一起,它们的工作原理如下:它类似于食品配送,我有一个餐厅应用程序,它将添加餐厅位置,我将通过纬度和经度在我的Firebase餐厅收藏中存储此位置。在另一个应用程序“eater”应用程序中,我想显示Firestore附近的餐厅文档(现在文档包括名称、图像和描述)

使用“食客”应用程序,我已经可以存储他们的当前位置。我唯一想做的就是展示附近的餐馆

这是我的ShowNearByCompanys()函数

Stream showNearbyCompanies() async* {
    var pos = await location.getLocation();

    GeoFirePoint point =
        geo.point(latitude: pos.latitude, longitude: pos.longitude);

    double distance = 30;

    double lat = 0.023323826086956514;
    double lon = 0.02926080000000002776;

    double lowerLat = point.latitude - (lat * distance);
    double lowerLon = point.longitude - (lon * distance);

    double greaterLat = point.latitude + (lat * distance);
    double greaterLon = point.longitude + (lon * distance);

    GeoPoint lesserGeoPoint = GeoPoint(lowerLat, lowerLon);
    GeoPoint greaterGeoPoint = GeoPoint(greaterLat, greaterLon);

    Query query = _firebaseFirestore
        .collection("Companies")
        .where("location", isGreaterThan: lesserGeoPoint)
        .where("location", isLessThan: greaterGeoPoint);

    yield query;
  }

**//This is another example instead of query**


showNearbyCompanies() async {
    var pos = await location.getLocation();

    GeoFirePoint point =
        geo.point(latitude: pos.latitude, longitude: pos.longitude);

    double distance = 30;

    Stream<List<DocumentSnapshot>> stream = geo
        .collection(collectionRef: _firebaseFirestore.collection("Companies"))
        .within(center: point, radius: distance, field: 'location');

    stream.listen((List<DocumentSnapshot> documentList) {
      // print(stream.length);
      print('Here');
      print(documentList[0].data());
    });
  }

你能发布ShownearByCompanys生成的查询结果吗?我该怎么做?我认为这是我的问题,我不知道一个小部件可以产生它。。。我正在使用一个文本小部件,但它返回的错误查询显然不是字符串类型…是的,它返回“查询实例”哈,在生成它之前您是否尝试打印
Query
?我假设
query
是一个映射或映射列表。query类是否公开
snapshots
方法?
Container(
            child: StreamBuilder(
              stream: showNearbyCompanies(),
              builder: (context, snapshot) {
                if (!snapshot.hasData) {
                  return Text("Loading");
                }
                return Text(snapshot.data); // this needs to be the query, I don't know how to do
              },
            ),
          ),