Leaflet.print
Leaflet.print copied to clipboard
(Help) - Error Message
Hi
I'm trying to use Leaflet.print, but when I click on the print button I get the following message:
"Uncaught TypeError: Cannot read property 'style' of undefined" -> leaflet.print-src.js:827
what's wrong? Thank's
Renato Becker
Hi Renato
It seems Leaflet Print needs to be updated in order to keep up with the Mapfish Print 3.3 protocol.
andrelsm
Same error%( But I use Geoserver 2.8.0 Is there any way to solve?
error_line:
_showActionsToolbar: function () {
L.DomUtil.addClass(this._toolbarContainer, 'leaflet-print-actions-visible');
this._actionsContainer.style.display = 'block'; //THIS LINE GENS ERROR!!!
this._actionsVisible = true;
},
Hi, which version of Leaflet are you using? I haven't done any work to upgrade this plugin to work with Leaflet 1.0 and due to the plugin needing to access private API properties it's quite likely it's not compatible with 1.0
0.7.3 from CDN
AFAICT that error is occurring in the print control when the print button is clicked before the print service capabilities document has been loaded. Can you check that you're either providing a capabilities configuration object when creating the print provider OR specifying the print service url
and autoLoad
options, and in the latter case that the capabilities response has returned before clicking the print button.
Well, i've found error. It was my fault. thank you
I'll update the code to throw an error if the capabilities document hasn't been loaded when the print actions are invoked. That should help with tracking down these issues in the future.
Thx... I'm getting now 400 (Bad request) error, when i tru to print the map. Capabilites are loading ok. but request to print
http://82.208.111.22:4040/print-servlet-2.1.0/pdf/print.pdf?spec=%7B%22units%22%3A%22m%22%2C%22srs%22%3A%22EPSG%3A3857%22%2C%22layout%22%3A%22A4%20portrait%22%2C%22dpi%22%3A90%2C%22outputFormat%22%3A%22pdf%22%2C%22outputFilename%22%3A%22leaflet-....
returns 400
is it fault of my server?
I would recommend using POST as the HTTP method as the layer data can be quite large. It's possible your HTTP server is truncating the URL.
And is there any WORKING example with POST using. I'm getting error "no create.json method"
Thnaks in advance
Here's an example from a project we're using Leaflet Print on:
var printProvider = L.print.provider({
autoOpen: false,
map: map,
capabilities: printConfig,
proxy: <proxy url> + '?url=',
method: 'POST',
layout: 'Map Only',
dpi: 72,
outputFormat: 'png'
}
});
The printConfig
global is created by the request to the mapfish print info.json resource:
<script type="text/javascript" src="<map-fish-print>/info.json?var=printConfig"></script>