简体   繁体   English

如何将数据从 firebase 应用程序传递到 flutter 中的谷歌 map

[英]How to pass data from firebase app to google map in flutter

I want to send or pass some data from Firebase inside my app into google map我想从我的应用程序内的 Firebase 发送或传递一些数据到谷歌 map
for example I want to send and display some "coordinate" or "itinerary" of a shop例如我想发送和显示一些商店的“坐标”或“行程”

The snippet code below launch google map using url_launcher下面的代码片段使用 url_launcher 启动 google map
I don't know how to do the rest.我不知道怎么做 rest。 Any ideas I could use some examples?有什么想法我可以举一些例子吗?

    void _openMap() async {
      const url = 'https://www.google.com/maps/search/?api=1&query=52.32,4.917';
      if (await canLaunch(url)) {
        void initState(){
          super.initState();
          canLaunch( "https://maps.google.com/maps/search");
        }

        await launch(url);
      } else {
        throw 'Could not launch $url';
      }
    }

The code below is for creating records inside firebase下面的代码用于在 firebase 中创建记录

    void createRecord(){
  databaseReference.child("1").set({
    'name': 'Macdonald',
    'location': 'New york'
  });
  databaseReference.child("2").set({
    'name': 'burger king',
    'location': 'Mexico'
  });
}

Edit: There is multiple shop with different location (document id) ex: macdonald, burger king...etc编辑:有多个不同位置的商店(文件ID)例如:麦当劳,汉堡王......等

Screenshot example截图示例

If your data is in Firebase collection then you have to just fetch the coordinates from your Firestore collection and pass it to the above URL.如果您的数据在 Firebase 集合中,那么您只需从 Firestore 集合中获取坐标并将其传递给上述 URL。 now fetching the coordinates from your collection can be done by below code first you will fetch all documents and then you will get the field of each document现在可以通过以下代码从您的集合中获取坐标,首先您将获取所有文档,然后您将获取每个文档的字段

final QuerySnapshot result =
          await Firestore.instance.collection('YOUR COLLECTION Name').getDocuments();
final List<DocumentSnapshot> documents = result.documents;

documents.forEach((data) {
 var cordinates = doc.data['coordinates'];
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从地图对象 Firebase (Flutter) 获取数据 - How to get Data from map objects Firebase (Flutter) 如何建立地图 <DateTime, List> 从扑火的Firebase数据 - How to build a Map<DateTime, List> from firebase data in flutter 如何更新阵列中的 map 数据? Flutter firebase - How to update map data in Array? Flutter firebase 如何对 firebase 中的数据进行排序? 在 flutter 应用程序内 - how to sort the data from firebase? inside a flutter app 如何将数据从C ++桌面应用程序发送到Google Firebase? - How to send data from C++ desktop App to Google Firebase? 将 Firebase 中的地图数据检索到 Flutter - Retrieve Map Data in Firebase to Flutter 使用 firebase google 登录后,如何在 Flutter 应用程序中保存或保留要在我的设置页面中使用的数据 - How to save or keep data to be used in my settings page after sign in using firebase google sign in, in flutter app Flutter:如何从 Firebase 快照创建 Map 并使用相同的键合并数据 - Flutter: how to create Map from firebase snapshot and merge data with same key 如何从 firebase map 数据 Flutter 中创建一个按 int 值排序的排序列表 - How can I make a sortlist ordered by int value from firebase map data Flutter Flutter firebase,如何将数据插入数组 Map 数组 - Flutter firebase, How to insert data to Array Map Array
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM