【问题标题】:save LatLng(geopoint) value in firestore document / geolocator package在 Firestore 文档/地理定位器包中保存 LatLng(geopoint) 值
【发布时间】:2020-08-26 23:17:38
【问题描述】:

我是 Flutter 的新手,我需要在我的用户文档中保存一个值。 我可以打印这些值,但我不知道如何将 LatLan 的值分配给一个变量并将它们保存在 firestore 中。 这是我的 searchMapPlaceWidget 返回它们的值

 SearchMapPlaceWidget(
   darkMode: true,
   placeType: PlaceType.establishment,
   language: 'se',
   apiKey: kGoogleApiKey,
   onSelected: (place) async {
     final geolocation =
       await place.geolocation;

     final chosenPlace = Marker(
       markerId: MarkerId(
         'chosen-location'),
       icon: BitmapDescriptor
       .defaultMarker,
       position:
       geolocation.coordinates);
     GoogleMapController controller =
       await _mapController.future;
     setState(() {
       _markers.add(chosenPlace);
     });
     print(chosenPlace.position);

     controller.animateCamera(
       CameraUpdate.newLatLng(
         geolocation.coordinates));
     controller.animateCamera(
       CameraUpdate.newLatLngBounds(
         geolocation.bounds, 50));
   },

 ),

这是我写的函数不起作用????

static void addGeoPoint(User user)async{
var pos = await location.getLocation();
GeoFirePoint point = geo.point(latitude: pos.latitude, longitude: pos.longitude);
return usersRef.document(user.id).updateData({
  'myAddress' : point.data
});

}

如何保存 'chosenPlace' 的位置值?

谢谢大家

【问题讨论】:

    标签: google-maps flutter google-cloud-firestore geolocation


    【解决方案1】:

    解决了。

     GeoFirePoint myLocation = geo.point(latitude: _location.latitude, longitude: _location.longitude);
                                                  usersRef.document(widget.user.id).updateData({
                                                    'position' : myLocation.data
    

    【讨论】:

      猜你喜欢
      • 2019-05-16
      • 1970-01-01
      • 2021-05-07
      • 1970-01-01
      • 1970-01-01
      • 2019-02-09
      • 1970-01-01
      • 2021-11-10
      • 2018-06-25
      相关资源
      最近更新 更多