1

I want to print google maps when user clicks on the print button. I'm using the window.print() to print the page. From a research that I did most of the examples are doing a snapshot of the map and printing only the map on another page. As you can see in the image that I have attached, it shows the Google logo a pin but not the map. I added display:block !important but still is not showing the map on print. Does anyone knows how I can print the map including other details. enter image description here

Thank you

George Panayi
  • 1,768
  • 6
  • 26
  • 42

1 Answers1

2

So you need to manipulate the javascript in the answer I gave in my comment above in order to include additional content. Here is a working example.

function printMaps() {
  var body               = $('body');
  var appendMap          = $('#before_map');
  var prependMap         = $('#after_map');
  var mapContainer       = $('.map-container');
  var printContainer     = $('<div>');

  printContainer
    .prepend(appendMap)
    .addClass('print-container')
    .css('position', 'relative')
    .height(mapContainer.height())
    .append(mapContainer)
    .append(prependMap)
    .prependTo(body);


  // Patch for some Bootstrap 3.3.x `@media print` styles. :|
  var patchedStyle = $('<style>')
    .attr('media', 'print')
    .text('img { max-width: none !important; }' +
          'a[href]:after { content: ""; }')
    .appendTo('head');

  window.print();

});

Complete fiddle here: http://jsfiddle.net/6mx21ted/141/

Its is based on answer Google Maps API V3 Printing Maps

Community
  • 1
  • 1
fat_mike
  • 877
  • 12
  • 27