Flutter 如何从firebase(颤振/飞镖)正确获取地理位置数据(纬度、经度)?

Flutter 如何从firebase(颤振/飞镖)正确获取地理位置数据(纬度、经度)?,flutter,dart,google-cloud-firestore,geolocation,Flutter,Dart,Google Cloud Firestore,Geolocation,这是我的火力基地 根据这个要求,我得到了这种数据 final firestoreInstance = Firestore.instance; firestoreInstance.collection("locations").getDocuments().then((querySnapshot) { querySnapshot.documents.forEach((result) { print(result.data); }); }); 下面是

这是我的火力基地 根据这个要求,我得到了这种数据

final firestoreInstance = Firestore.instance;
firestoreInstance.collection("locations").getDocuments().then((querySnapshot) {
      querySnapshot.documents.forEach((result) {
        print(result.data);
      });
    });
下面是服务器的响应

{12/5/2020: {geohash: u8vybwryv, geopoint: Instance of 'GeoPoint'}} .... and all list of documents
我用了这个之后

 firestoreInstance.collection("test").getDocuments().then((querySnapshot) {
      querySnapshot.documents.forEach((result) {
        print(result.data['geopoint'].latitude.toString());
      });
   });
并在调试null中接收


如何获取纬度和经度且不为空?

可能对某些人有帮助

List<LatLng> polyLinesLatLongs = List<LatLng>(); // our list of geopoints

_someFunction() {
    firestoreInstance
        .collection("userId") // your collection
        .document('history') //your document
        .collection("locations") //your collection
        .getDocuments()
        .then((querySnapshot) {
      var fireBase = querySnapshot.documents;
      for (var i = 1; i < fireBase.length; i++) {

        GeoPoint point = fireBase[i].data['position']['geopoint']; //that way to take instance of geopoint

        polyLinesLatLongs.add(LatLng(double.parse('${point.latitude}'),
              double.parse('${point.longitude}'))); // now we can add our point to list
    });
  }
List polyLinesLatLongs=List();//我们的地质点列表
_someFunction(){
firestoreInstance
.collection(“userId”)//您的集合
.document('history')//您的文档
.collection(“位置”)//您的收藏
.getDocuments()
.然后((querySnapshot){
var fireBase=querySnapshot.documents;
对于(变量i=1;i
媒体上有一篇文章叫做“在颤振中使用地理定位和地理编码(以及与地图的集成)”,我认为这篇文章可以帮助您解决您的问题: