Print osm using mapfish printservlet war file in tomcat
I have downloaded the war file of the mapfish print osm and deployed it in
the tomcat, and used the js files from
http://api.geoext.org/1.1/examples/print-preview-osm.html, but i'm having
an exception
org.mapfish.print.InvalidJsonValueException: spec.layers[0].type has an
invalid value: OSM
is it the right way to do to print the map or can anybody point me in
right direction..my code is:
Ext.onReady(function() {
// The PrintProvider that connects us to the print service
var printProvider = new GeoExt.data.PrintProvider({
url: "http://localhost:8000/print-servlet-1.1/pdf/print.pdf",
method: "GET", // "POST" recommended for production use
capabilities: printCapabilities, // provide url instead for lazy loading
customParams: {
mapTitle: "OSM Printing",
comment: "This demo shows how to use GeoExt.PrintMapPanel with OSM"
}
});
var map = new OpenLayers.Map();
map.addLayer(new OpenLayers.Layer.OSM());
var lonLat = new OpenLayers.LonLat( userLon ,userLat ).transform(
new
OpenLayers.Projection("EPSG:4326"), //
transform from WGS 1984
map.getProjectionObject() // to
Spherical Mercator Projection
);
var zoom=10;
var markers = new
OpenLayers.Layer.Markers( "Markers" );
map.addLayer(markers);
markers.addMarker(new
OpenLayers.Marker(lonLat));
map.setCenter (lonLat, zoom);
// A MapPanel with a "Print..." button
mapPanel = new GeoExt.MapPanel({
renderTo: "content",
width: 1000,
height: 800,
map: map,
zoom: 10,
bbar: [{
text: "Print...",
handler: function(){
// A window with the PrintMapPanel, which we can use to adjust
// the print extent before creating the pdf.
printDialog = new Ext.Window({
title: "Print Preview",
width: 500,
autoHeight: true,
items: [{
sourceMap: mapPanel,
printProvider: printProvider,
xtype: "gx_printmappanel",
// use only a PanPanel control
map: {controls: [new OpenLayers.Control.PanPanel()]}
}],
bbar: [{
text: "Create PDF",
handler: function(){ printDialog.items.get(0).print(); }
}]
});
printDialog.show();
}
}]
});
I have tried using without ext.js but was not able to get how to pass the
map div as parameter,so i used the geoext but that was giving the above
exception.
My config File:
hosts:
- !localMatch
dummy: true
- !ipMatch
ip: http://localhost:8000/print-servlet-1.1/
- !dnsMatch
host: localhost
port: 8000
- !dnsMatch
host: demo.mapfish.org
port: 8000
layouts:
mainPage:
rotation: true
pageSize: A4
header:
height: 50
items:
- !text
font: Helvetica
fontSize: 30
align: right
text: '${mapTitle}'
items:
- !map
spacingAfter: 30
width: 440
height: 483
- !text
text: '${comment}'
spacingAfter: 30
footer:
height: 30
items:
- !columns
items:
- !text
backgroundColor: #FF0000
align: left
text: Copyright Juventus Techonologies
- !text
align: right
text: 'Page ${pageNum}'
anybody help me out with please..
No comments:
Post a Comment