Skip to content

Instantly share code, notes, and snippets.

@wholypantalones
Last active August 29, 2015 14:14
Show Gist options
  • Select an option

  • Save wholypantalones/c37f89ad438f17f347a5 to your computer and use it in GitHub Desktop.

Select an option

Save wholypantalones/c37f89ad438f17f347a5 to your computer and use it in GitHub Desktop.
Get and fit the mutha f**king bounds of things on a google map
/*
mutha f**king angular-google-maps
http://angular-ui.github.io/angular-google-maps/#!/api
*/
$scope.findSquare = function(index) {
var boundaryLatLng = new google.maps.LatLngBounds(),
thisBounds = [];
// or do a forEach here for multiples
thisBounds.push(
{
name:"dunno",
latlng: new google.maps.LatLng(northLatitude,northLongitude)
},{
name:"dunno",
latlng: new google.maps.LatLng(southLatitude,southLongitude)
}
);
for (var i = 0; i < thisBounds.length; i++) {
boundaryLatLng.extend(thisBounds[i].latlng);
}
$scope.mapInstance.fitBounds(boundaryLatLng);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment