I’m pretty new (2 days in) to dart(flutter) so bare with me. I am trying to add markers to my open street maps map in my flutter app. I have a csv file with all the points I want to add that looks like this:
place_name | latitude | longitude |
---|---|---|
data | data | data |
I have figured out how to add a single marker – how can I loop through the rows in the csv file to add multiple markers? Here’s my current add marker code.
Future<void> _addSingleMarker() async {
// Given latitude and longitude
final latitude = 53.7827922;
final longitude = -1.5547318;
markers.clear();
markers.add(GeoPoint(latitude: latitude, longitude: longitude));
await _addMarkersToMap();
}
Future<void> _addMarkersToMap() async {
for (GeoPoint marker in markers) {
print("Adding marker at latitude: ${marker.latitude}, longitude: ${marker.longitude}");
await mapController.addMarker(marker,
markerIcon: const MarkerIcon(
icon: Icon(
Icons.location_pin,
color: Colors.blue,
size: 48,
),
));
}
print("Markers added to the map");