Skip to content

Instantly share code, notes, and snippets.

@koycarraway
Created January 11, 2013 14:46
Show Gist options
  • Save koycarraway/4511191 to your computer and use it in GitHub Desktop.
Save koycarraway/4511191 to your computer and use it in GitHub Desktop.
Center Google Map (v3) during browser resize
var center;
function calculateCenter() {
center = map.getCenter();
}
google.maps.event.addDomListener(map, 'idle', function() {
calculateCenter();
});
google.maps.event.addDomListener(window, 'resize', function() {
map.setCenter(center);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment