Jessica
Jessica

Reputation: 9830

Find center and zoom into all LatLng

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

Answers (1)

Kryptic1
Kryptic1

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

Related Questions