0

I have multiple LatLng Using this library: https://pub.dev/packages/google_maps_flutter how can I get their center and zoom into the map so that all the LatLng are visible, but not too far from the screen?

Jessica
  • 9,379
  • 14
  • 65
  • 136

1 Answers1

-2

I found this on a similar question so I hope it applies... (Center/Set Zoom of Map to cover all visible Markers?)

var markers = [];//some array
var bounds = new google.maps.LatLngBounds();
for (var i = 0; i < markers.length; i++) {
 bounds.extend(markers[i]);
}

map.fitBounds(bounds);

Possibly take a look at their documentation: https://developers.google.com/maps/documentation/javascript/reference/map#Map.fitBounds

Kryptic1
  • 1
  • 3