Reputation: 9830
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?
Upvotes: 0
Views: 50
Reputation: 1
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
Upvotes: -2