首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >想要从颤振云存储中的多个文档中获取特定的文档字段

想要从颤振云存储中的多个文档中获取特定的文档字段
EN

Stack Overflow用户
提问于 2021-04-24 07:02:14
回答 1查看 339关注 0票数 0

这张图片有数据库

我想抓住所有文件的纬度和经度,并将其显示在颤振地图(传单)中。

代码语言:javascript
复制
FlutterMap(
      options: MapOptions(
        center: latLng.LatLng(51.5, -0.09),
        zoom: 13.0,
      ),
      layers: [
        TileLayerOptions(
            urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
            subdomains: ['a', 'b', 'c']),
        MarkerLayerOptions(
          markers: [
            Marker(
              width: 80.0,
              height: 80.0,
              point: latLng.LatLng(51.5, -0.09),
              builder: (ctx) => Container(
                child: Icon(
                  Icons.circle,
                  size: 30,
                  color: dc,
                ),
              ),
            ),
          ],
        ),
      ],
    );

我把第15行作为示例,我想访问所有用户的lat长度。请帮忙,并提前感谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-04-24 09:37:14

  • 首先,您必须为您的shopkeepers获取文档。
  • 然后,遍历这些文档,提取lat和lng值,并将它们添加到列表中。
代码语言:javascript
复制
Future<List<LatLng>> getCordsFromFirebase() async {
List<LatLng> coordinatesList=[];
var results = await FirebaseFirestore.instance.collection('shopkeepers').get();

for (DocumentSnapshot item in results.docs){
coordinatesList.add(LatLng(item.data()['latitidue'], item.data()['longitude]));
 }
print('Length of cords list is: ' + coordinatesList.length.toString());//
return coordinatesList;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67240152

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档