Created
August 18, 2016 10:31
-
-
Save seutje/c3f5f4525bfc539e0091aa1a10980222 to your computer and use it in GitHub Desktop.
Resize map for print.
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
var map; | |
var printHandler = function(e) { | |
// Grab center before resize. | |
var center = map.getCenter(); | |
// Tell the map it needs to resize. | |
window.google.maps.event.trigger(map, 'resize'); | |
// Set the center back to what it was pre-resize. | |
map.setCenter(center); | |
}; | |
window.initMap = funciton() { | |
... | |
map = new google.maps.Map(mapWrap, { | |
zoom: parseInt(location['zoom'], 10), | |
center: myLatLng | |
}); | |
// Everything but webkits | |
if (window.onbeforeprint !== undefined) { | |
$(window).bind('onbeforeprint', printHandler); | |
} | |
// Webkits | |
else if (window.matchMedia) { | |
window.matchMedia('print').addListener(printHandler); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment