2020年12月22日星期二

How to fetch multi markers map from firestore - flutter

i have list database in firestore with collection 'DriverData' and the field : email,driverLat,driverLong

how to fetch it to google map marker? i already try this code..

 Set<Marker> _markers = {};        BitmapDescriptor mapMarker;            void setCustomMarker() async {      mapMarker = await BitmapDescriptor.fromAssetImage(          ImageConfiguration(), 'assets/driving_pin.png');    }           _onMapCreated(GoogleMapController controller) async {  FirebaseFirestore.instance.collection('DriverData').get().then((value) {        if (value.docs.isNotEmpty) {          for (int i = 0; i < value.docs.length; i++) {            _location.onLocationChanged.listen((l) {              _controller.animateCamera(                CameraUpdate.newCameraPosition(                  CameraPosition(                      target: LatLng(value.docs[i].data()['driverLat'],                          value.docs[i].data()['driverLong']),                      zoom: 19),                ),              );}  

and the display

GoogleMap(                   onMapCreated: _onMapCreated,                  markers: _markers,                  initialCameraPosition: CameraPosition(                    target: LatLng(0, 0),                    zoom: 18,                  ))),  

how to do the right way ?

https://stackoverflow.com/questions/65418155/how-to-fetch-multi-markers-map-from-firestore-flutter December 23, 2020 at 10:06AM

没有评论:

发表评论