Skip to content

Instantly share code, notes, and snippets.

@kbshl
Created October 27, 2015 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kbshl/3c432f310aab321196e1 to your computer and use it in GitHub Desktop.
Save kbshl/3c432f310aab321196e1 to your computer and use it in GitHub Desktop.
Google MAP API v3: Center & Zoom on displayed markers Source: http://stackoverflow.com/a/2819013
// map: an instance of GMap3
// latlng: an array of instances of GLatLng
var mapBounds = new google.maps.LatLngBounds();
latlng.each(function(n) {
mapBounds.extend(n);
return;
});
map.setCenter(mapBounds.getCenter());
map.fitBounds(mapBounds);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment