如何从火力地堡(颤振/飞镖)正确获取地理位置数据(纬度,经度)?

时间:2020-05-14 13:15:15

标签: flutter dart google-cloud-firestore geolocation

enter image description here

这是我的基地 根据这个请求,我得到了这类数据

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。

如何获取经度而不是空值?

1 个答案:

答案 0 :(得分:0)

可能对某人有帮助

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
    });
  }