Skip to content

Instantly share code, notes, and snippets.

@thiagoeliasr
Created September 4, 2015 13:30
Show Gist options
  • Save thiagoeliasr/970417ff9c8fb7ce9c9f to your computer and use it in GitHub Desktop.
Save thiagoeliasr/970417ff9c8fb7ce9c9f to your computer and use it in GitHub Desktop.
Google Maps API: Center / Zoom in bounds
// Create a new viewpoint bound
var bounds = new google.maps.LatLngBounds();
// Go through each...
for (var i = 0, LtLgLen = _latlng.length; i < LtLgLen; i++) {
// And increase the bounds to take this point
bounds.extend (_latlng[i]);
}
// Fit these bounds to the map
map.fitBounds(bounds);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment