[英]How to pass data from firebase app to google map in flutter
我想从我的应用程序内的 Firebase 发送或传递一些数据到谷歌 map
例如我想发送和显示一些商店的“坐标”或“行程”
下面的代码片段使用 url_launcher 启动 google map
我不知道怎么做 rest。 有什么想法我可以举一些例子吗?
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';
}
}
下面的代码用于在 firebase 中创建记录
void createRecord(){
databaseReference.child("1").set({
'name': 'Macdonald',
'location': 'New york'
});
databaseReference.child("2").set({
'name': 'burger king',
'location': 'Mexico'
});
}
编辑:有多个不同位置的商店(文件ID)例如:麦当劳,汉堡王......等
如果您的数据在 Firebase 集合中,那么您只需从 Firestore 集合中获取坐标并将其传递给上述 URL。 现在可以通过以下代码从您的集合中获取坐标,首先您将获取所有文档,然后您将获取每个文档的字段
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.