Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print map in LeafletJS

Tags:

leaflet

I am new in LeafletJS. I am trying to print map in LeafletJS. My code for print is like this:

     printProvider = L.print.provider({
      capabilities: printConfig,
      method: 'GET',
      dpi: 254,
      autoLoad: true,
      // outputFormat: 'pdf',
      customParams: {
          mapTitle: 'Print Test',
          comment: 'Testing Leaflet printing'
      }
  });
  // Create a print control with the configured provider and add to the map
  printControl = L.control.print({
      provider: printProvider
  });
  map.addControl(printControl);

But when I click the print button error comes like this

Proxy Error.
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /mapfish-print/pdf/print.pdf.

Reason: Error reading from remote server

Can anyone help me?

like image 318
shrestha Avatar asked Apr 27 '14 10:04

shrestha


1 Answers

You can use jQuery Plugin to print a map.

The code is as simple as

$('#map').print();

Here is the codepen.

like image 127
artem_p Avatar answered Oct 11 '22 14:10

artem_p