Center Google Map (v3) during browser resize


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. var center;
  2. function calculateCenter() {
  3. center = map.getCenter();
  4. }
  5. google.maps.event.addDomListener(map, 'idle', function() {
  6. calculateCenter();
  7. });
  8. google.maps.event.addDomListener(window, 'resize', function() {
  9. map.setCenter(center);
  10. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.