[英]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)例如:麦当劳,汉堡王......等
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.