firebase - Flutter Firestore甚至在提供orderby函数后仍以错误的顺序获取

标签 firebase flutter dart google-cloud-firestore

这是代码,

final Set<Polyline> _polylines = {};
  List<LatLng> latlngList = List();
  static var today = DateTime.now();
  String Daily = DateFormat('yyyy-MM-dd').format(today);

  void getLocation() async {
    final location = await _firestore
        .collection('$Daily')
        .orderBy('time', descending: false)
        .getDocuments();
    for (var location in location.documents) {
      LatLng lat =
          LatLng(location.data['latittude'], location.data['longitude']);
      latlngList.add(lat);
      _polylines.add(Polyline(
          polylineId: PolylineId('adress'),
          color: Colors.blue,
          visible: true,
          width: 5,
          points: latlngList));
      setState(() {
        _markers.add(Marker(
          markerId: MarkerId('addr'),
          position: lat,
          draggable: true,
          infoWindow: InfoWindow(
            title: latlngList[0].toString(),
            snippet: '5 Star Rating',
          ),
          icon: BitmapDescriptor.defaultMarker,
        ));
      });
    }
  }

当我在Google map 小部件上使用它来显示标记和折线时。它以错误的顺序显示Output Image I am getting
和实际的输入路径,我添加了input of marker I provided。红线实际上是我在输入时给出的标记

最佳答案

尝试更改markerId

markerId = MarkerId('addr')

而是使用MarkerId('adress')或具有动态值(value)的东西

关于firebase - Flutter Firestore甚至在提供orderby函数后仍以错误的顺序获取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60299558/

相关文章:

ios - 如何读取 Firebase 子值?

firebase - 调用Firebase的 "Bad request"方法时如何防止 `.onCall()`?

database - FutureBuilder 与 Streambuilder

javascript - 按日期分隔符对邮件进行排序

firebase - 如何在具有多个优先级的 Firebase 中进行排序?

当 TextField 值更改时 Flutter FutureBuilder 刷新

Flutter 热重载无法显示更改

dart - 右对齐而不调整父级大小

javascript - 用于推送通知的Firebase云功能不起作用

flutter - 使用条件在Flutter中选择不同的小部件集