Reputation: 47
I wanted to grab the latitude and longitude of all documents and display it in flutter map (leaflet).
FlutterMap(
options: MapOptions(
center: latLng.LatLng(51.5, -0.09),
zoom: 13.0,
),
layers: [
TileLayerOptions(
urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
subdomains: ['a', 'b', 'c']),
MarkerLayerOptions(
markers: [
Marker(
width: 80.0,
height: 80.0,
point: latLng.LatLng(51.5, -0.09),
builder: (ctx) => Container(
child: Icon(
Icons.circle,
size: 30,
color: dc,
),
),
),
],
),
],
);
I put line 15 just for sample, i wanted to access all the user's lat long . please help, and thanks in advance
Upvotes: 0
Views: 519
Reputation: 12373
shopkeepers
.
Future<List<LatLng>> getCordsFromFirebase() async {
List<LatLng> coordinatesList=[];
var results = await FirebaseFirestore.instance.collection('shopkeepers').get();
for (DocumentSnapshot item in results.docs){
coordinatesList.add(LatLng(item.data()['latitidue'], item.data()['longitude]));
}
print('Length of cords list is: ' + coordinatesList.length.toString());//
return coordinatesList;
}
Upvotes: 0