Reputation: 233
I am trying to print a map I have created with Google Maps API v3. The map contains a polygon. I am using the pop-up method to try to print it:
var gmapPrint = function() {
var content = window.document.getElementById('map-canvas') // get you map details
var newWindow = window.open(); // open a new window
newWindow.document.write(content.innerHTML); // write the map into the new window
newWindow.print(); // print the new window
}
The map prints just fine, but the polygon is missing. At first, it seemed as though the print dialog was popping up before the polygon was drawn on the map, so I added a setTimeout. This did not fix the issue. I have also tried using the static maps API, but the number of points in the boundary of my polygon exceed the maximum URL size, even when encoded.
Has anyone had any success with this?
Upvotes: 4
Views: 8302
Reputation: 233
Ok, so Beetroot-Beetroot's comment got me on the right track. I had seen that post earlier and gave it a quick shot without much luck, but now I've got it working.
Here is a snippet to print a google map without the controls visible.
https://gist.github.com/jawsthegame/6801698
Upvotes: 6