Created
August 8, 2012 01:42
-
-
Save yuanmai/3291295 to your computer and use it in GitHub Desktop.
Google map fitBounds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Make an array of the LatLng's of the markers you want to show | |
var LatLngList = array (new google.maps.LatLng (52.537,-2.061), new google.maps.LatLng (52.564,-2.017)); | |
// Create a new viewpoint bound | |
var bounds = new google.maps.LatLngBounds (); | |
// Go through each... | |
for (var i = 0, LtLgLen = LatLngList.length; i < LtLgLen; i++) { | |
// And increase the bounds to take this point | |
bounds.extend (LatLngList[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
nice. thanks for this!