Firebase 如何将地质点上载到firestore?

Firebase 如何将地质点上载到firestore?,firebase,flutter,dart,google-cloud-firestore,geopoints,Firebase,Flutter,Dart,Google Cloud Firestore,Geopoints,我必须将两个坐标保存到我的firestore,但我必须将它们保存为geopoint在firestore中键入。我有来自GMAP的数据(LatLng),不知道如何将它们作为地质点上传。我还尝试在公司位置之后不使用.toString()上传列表,但是整个函数都不起作用。当我运行我目前拥有的代码时,数据被上传为字符串,这是因为我使用了.toString() 我尝试了以下方法: 我创建了一个新的LatLng: LatLng companyLocation; 我有通过点击地图获取数据的功能: List&

我必须将两个坐标保存到我的firestore,但我必须将它们保存为
geopoint
在firestore中键入。我有来自GMAP的数据(
LatLng
),不知道如何将它们作为
地质点上传。我还尝试在
公司位置
之后不使用
.toString()
上传列表,但是整个函数都不起作用。当我运行我目前拥有的代码时,数据被上传为字符串,这是因为我使用了
.toString()

我尝试了以下方法:

我创建了一个新的
LatLng

LatLng companyLocation;
我有通过点击地图获取数据的功能:

List<Marker> myMarker = [];

  _onTap(LatLng tappedPoint) {
    setState(() {
      myMarker = [];
      myMarker.add(
        Marker(
          markerId: MarkerId(tappedPoint.toString()),
          position: tappedPoint,
        ),
      );
      companyLocation = tappedPoint;
      print(companyLocation);
    });
  }
List myMarker=[];
_onTap(LatLng tappedPoint){
设置状态(){
myMarker=[];
myMarker.add(
标记(
markerId:markerId(tappedPoint.toString()),
位置:tappedPoint,
),
);
公司地点=tappedPoint;
印刷(公司地址);
});
}
然后我尝试将包含数据的列表上载到我的firestore:

 Map<String, dynamic> data = {
      'name': nameController.text,
      'location': companyLocation.toString(),
    };
地图数据={
“名称”:nameController.text,
“位置”:companyLocation.toString(),
};
我尝试了下面评论中提到的代码,但是我得到了一个错误(地质点有红色下划线),为什么我会得到这个


这是一个屏幕截图

检查这篇文章:但是当我尝试这个代码时:新的地理点(纬度:companyLocation.latitude,经度:companyLocation.longitude);然后,地质点在红色下划线。这可能有助于红线错误消息告诉您什么?您的代码顶部是否有这一行:import“package:cloud\u firestore/cloud\u firestore.dart”;?我用一个屏幕截图来编辑这个问题,以显示什么是红色的