I´m trying to add a print function to my GeoExt MapPanel, using the following code:
bbar: ["->", {
text: "Print...",
handler: function() {
var printDialog = new Ext.Window({
items: [new GeoExt.PrintMapPanel({
sourceMap: mapPanel,
printProvider: new GeoExt.data.PrintProvider({
method: "GET",
url: "/geoserver/pdf",
listeners: {
"loadcapabilities": function() {
var printPage = new GeoExt.data.PrintPage();
printPage.fit(mapPanel, true);
printProvider.print(mapPanel, printPage);
}
},
customParams: {
mapTitle: "LVR WebGIS",
comment: "created with GeoExt"
}
})
})],
bbar: [{
text: "Create PDF",
handler: function() {
printDialog.items.get(0).print();
}
}]
});
printDialog.show();
}
}]
Using this code, I get the firebug error message
this.printProvider.layout is null
in line 240 of the PrintMapPanel.js
239 adjustSize: function(width, height) {
240 var printSize = this.printProvider.layout.get("size");
241 var ratio = printSize.width / printSize.height;
when trying to print the MapPanel.
Do I have to add a size/layout definition somewhere in the code or in the config.yaml of the print provider?
Best Answer
The map definitions should be in the YAML file. These are then accessed through the print web service via the info.json page.
http://www.mapfish.org/doc/print/protocol.html
For testing you can always hardcode these parameters by creating a JSON object:
You can try this with the GeoExt example at http://api.geoext.org/1.0/examples/print-page.js Replace the printCapabilities with a hard-coded JSON object like above. Once this is working then get the JSON dynamically from the web service.