aratcliffe / Leaflet.print

Plugin for printing a Leaflet map using either Mapfish or the GeoServer print module.
114 stars 40 forks source link

How to use MapFish print with leaflet #23

Open BasmaNabil opened 7 years ago

BasmaNabil commented 7 years ago

Hello,

I am new with Mapfish print,i want to to use it with leaflet to print a map,i used the following code var printProvider = L.print.provider({ method: 'GET', url: 'http://ip:8080/print', autoLoad: true, outputFormat: 'pdf', dpi: 90 }); var printControl = L.control.print({ provider: printProvider }); mymap.addControl(printControl);

And i got this error:GET http://ip:8080/print/info.json net::ERR_NAME_NOT_RESOLVED I know he is right but how can i solve it?

aratcliffe commented 7 years ago

That's a DNS issue. Your browser isn't resolving "ip" to your server running mapfish print. Is this running locally on your development machine and do you have an appropriate entry in your hostfile?

BasmaNabil commented 7 years ago

Yes I am running it locally

aratcliffe commented 7 years ago

Then you either need an entry for the hostname "ip" in your hostfile or access it as localhost.

BasmaNabil commented 7 years ago

i changed it to 'url: 'http://localhost:9090/print'' as this is the port for tomcat I got this 2 errors XMLHttpRequest cannot load http://localhost:9090/print/info.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. The response had HTTP status code 404. GET http://localhost:9090/print/info.json 404 (Not Found)

aratcliffe commented 7 years ago

This is a CORS issue. You will need to proxy the request to mapfish from your application domain and port.