hi, I'm having some problems generating the pdf file for printing the map i'm displaying. There it goes the code, when I click on the button, it doesn't generate anything. I hope someone can hel me.
*Ext.onReady(function() {
Ext.QuickTips.init();
OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";
//Impresio
var
printCapabilities={"scales":[{"name":"1:25,000","value":"25000"},{"name":"1:50,000","value":"50000"},{"name":"1:100,000","value":"100000"},{"name":"1:200,000","value":"200000"},{"name":"1:500,000","value":"500000"},{"name":"1:1,000,000","value":"1000000"},{"name":"1:2,000,000","value":"2000000"},{"name":"1:4,000,000","value":"4000000"}],"dpis":[{"name":"75","value":"75"},{"name":"150","value":"150"},{"name":"300","value":"300"}],"layouts":[{"name":"A4
portrait","map":{"width":440,"height":483},"rotation":true},{"name":"Legal","map":{"width":440,"height":483},"rotation":false}],"printURL":"http://demo.opengeo.org/geoserver/pdf/print.pdf","createURL":"http://demo.opengeo.org/geoserver/pdf/create.json"};
// The printProvider that connects us to the print service
var printProvider = new GeoExt.data.PrintProvider({
method: "GET",
// "POST" recommended for production use
capabilities:
printCapabilities, // from the info.json script in the
html
customParams: {
mapTitle: "Printing Demo"
}
});
// Our print page. Stores scale, center and rotation and gives
us a page
// extent feature that we can add to a layer.
printPage = new GeoExt.data.PrintPage({
printProvider: printProvider
});
map = new OpenLayers.Map({
maxExtent: new
OpenLayers.Bounds(388831.202, 4567418.41, 470957.848,
4619293.905),
allOverlays: false,
units: "m",
//llEVAM ELS CONTROLS PER
DEFECTE DE OPEN LAYERS, SI ELS VOLEM ACTIVAR
HEM DE SUPRIMIR ELS CONTROLS
controls: [
new
OpenLayers.Control.Navigation(),
new
OpenLayers.Control.ArgParser(),
new
OpenLayers.Control.Attribution()
],
projection: "EPSG:23031",
maxResolution:
"394.0499140625002",
minScale:50000,
maxScale:500});
var base = [
new OpenLayers.Layer.WMS(
"Ortofoto 1:500",
"http://shagrat.icc.es/lizardtech/iserv/ows? ",
{layers: "orto5m", format:"image/jpeg",
exceptions:
"application/vnd.ogc.se_xml"},
{isBaseLayer:true, singleTile:true,
'ratio':1}),
new OpenLayers.Layer.WMS(
"Topografic 1:500",
"http://shagrat.icc.es/lizardtech/iserv/ows? ",
{layers: "mtc5m", format:"image/jpeg",
exceptions:
"application/vnd.ogc.se_xml"},
{isBaseLayer:true, singleTile:true,
'ratio':1}),
];
var punts = [
new OpenLayers.Layer.WMS(
"Punts",
"http://localhost:8080/geoserver/cite/wms?",
{
layers: [
"W_PUNT_AFECCIO",
"W_CASETA",
"W_HIDRANT"
],
transparent:true,
format: "image/gif"
},{
isBaseLayer: false,
visibility: false,
buffer: 0,
}),
];
var linea = [
new OpenLayers.Layer.WMS(
"Linea",
"http://localhost:8080/geoserver/cite/wms?",
{
layers: [
"CANONADA"
],
transparent:true,
format: "image/gif"
},{
isBaseLayer: false,
visibility: false,
buffer: 0,
}),
];
var poly = [
new OpenLayers.Layer.WMS(
"Poly",
"http://localhost:8080/geoserver/cite/wms?",
{
layers: [
"W_POU"
],
transparent:true,
format: "image/gif"
},{
isBaseLayer: false,
visibility: false,
buffer: 0,
}),
];
var tema = [
new OpenLayers.Layer.WMS(
"Diametre Canonada",
"http://localhost:8080/geoserver/cite/wms?",
{
layers: [
"CANO_DIA_600",
"CANO_DIA_300_600",
"CANO_DIA_300"
],
transparent:true,
format: "image/gif"
},{
isBaseLayer: false,
visibility: false,
buffer: 0,
}),
];
var tema2 = [
new OpenLayers.Layer.WMS(
"Material de la Canonada",
"http://localhost:8080/geoserver/cite/wms?",
{
layers: [
"MATERIAL_POLI",
"MATERIAL_ASH "
],
transparent:true,
format: "image/gif"
},{
isBaseLayer: false,
visibility: false,
buffer: 0,
}),
];
vectorLayer = new OpenLayers.Layer.Vector();
//vectorLayer.displayInLayerSwitcher = true;
map.addLayers(base);
map.addLayers(punts);
map.addLayers(linea);
map.addLayers(poly);
map.addLayers(tema);
map.addLayers(tema2);
//TOOLS
// Pan
action = new GeoExt.Action({
text: "",
control: new
OpenLayers.Control.Pan(),
tooltip: "Pan",
map: map,
iconCls: 'pan'
});
actions["pan"] = action;
toolbarItems.push(action);
toolbarItems.push("-");
// Tool MAXEXTENT
action = new GeoExt.Action({
text: "",
control: new
OpenLayers.Control.ZoomToMaxExtent(),
tooltip: "Maxima
Extensio",
map: map,
iconCls: 'maxextent'
});
actions["max_extent"] = action;
toolbarItems.push(action);
toolbarItems.push("-");
//zoom ventana
action = new GeoExt.Action({
text: "",
control: new
OpenLayers.Control.ZoomBox(),
tooltip: "Zoom Pan",
enableToggle: true,
map: map,
iconCls: 'zoompan'
});
actions["zoompan"] = action;
toolbarItems.push(action);
toolbarItems.push("-");
// acció Identificar
var identificar = new OpenLayers.Control.WMSGetFeatureInfo({
hover: false,
drilldown: true,
info_format:'text/plain',
maxFeatures: 100,
url:"http://localhost:8080/geoserver/cite/wms?",
layers: punts,
eventListeners:{
getfeatureinfo: function(event) {
crearPopUp(event);
}
}
});
function crearPopUp(event){
var popup=new GeoExt.Popup({
title: "Info",
location: event.xy,
width: 200,
map: map,
html: event ,
autoDestroy: true,
autoScroll: true
});
popup.show();
}
action = new GeoExt.Action({
control: identificar,
map:map,
enableToggle: true,
tooltip: "Identificar",
text: "Info"
});
actions["Info"] = action;
toolbarItems.push(action);
toolbarItems.push("-");
// scale line
action = new GeoExt.Action({
text: "Scale",
control: new OpenLayers.Control.ScaleLine({
geodesic: true,
displayClass:'scale'
}),
map: map,
iconCls: ''
});
//mapa guia
var mapaguia = new OpenLayers.Control.OverviewMap({
maximized: false
});
map.addControl(mapaguia);
// Tool MOUSE POSISITION,passem el mouse i ens dona la
coordenada
action = new GeoExt.Action({
text: "Activa Coordenades",
control: new OpenLayers.Control.MousePosition({
displayClass:'mouse_position'
}),
map: map,
iconCls: ''
});
panel = new GeoExt.MapPanel({
height: 600,
width: 1000,
map:map,
region: 'center',
title: 'Visor ATLL',
zoom: 1,
tbar: toolbarItems,
items: [{ //Añade una barra de
zoom de GeoExt
xtype:
"gx_zoomslider", //Tipo de objeto
vertical: true,
//Horientación vertical
height: 120,
//Alto en píxels
x: 10,
//Posición horizaontal en píxels
y: 8,
//Posición vertical en píxels
plugins: new
GeoExt.ZoomSliderTip({template:"1:{scale}"}) //Añade un
tooltip de escalas
},
]
//slider de geoext (prova)
});
//Llegenda
var legendPanel = new GeoExt.LegendPanel({
map: map,
title: 'Legend Panel',
defaults: {
style:
'padding:5px',
baseParams: {
FORMAT: 'image/png',
LEGEND_OPTIONS: 'forceLabels:on'
}
},
region: "east",
width: 218,
heigth: 50,
collapsible: true,
title: "Llegenda",
split: true,
});
//TREEE NODES
// Crear el nostre propi layer node UI class, usant
TreeNodeUIEventMixin
var LayerNodeUI = Ext.extend(GeoExt.tree.LayerNodeUI, new
GeoExt.tree.TreeNodeUIEventMixin());
var treeConfig = new OpenLayers.Format.JSON().write([{
nodeType: "gx_baselayercontainer",
},{
nodeType: "gx_layer",
layer:
"Punts",
isLeaf:
false,
//
Crear subnodes dels layers en el LAYERS param. Si asignam
// un
loader al LayerNode i no li asignam un loader class, el
//
LayerParamLoader sera automaticament asumit.
loader:
{
param: "LAYERS"
}
},{
nodeType: "gx_layer",
layer:
"Linea",
isLeaf:
false,
//
Crear subnodes dels layers en el LAYERS param. Si asignam
// un
loader al LayerNode i no li asignam un loader class, el
//
LayerParamLoader sera automaticament asumit.
loader:
{
param: "LAYERS"
}
},{
nodeType: "gx_layer",
layer:
"Poly",
isLeaf:
false,
//
Crear subnodes dels layers en el LAYERS param. Si asignam
// un
loader al LayerNode i no li asignam un loader class, el
//
LayerParamLoader sera automaticament asumit.
loader:
{
param: "LAYERS"
}
},
], true);
var LayerNodeUItema = Ext.extend(GeoExt.tree.LayerNodeUI, new
GeoExt.tree.TreeNodeUIEventMixin());
var treeConfigtema = new OpenLayers.Format.JSON().write([
{
nodeType: "gx_layer",
layer:
"Diametre Canonada",
isLeaf:
false,
//
Crear subnodes dels layers en el LAYERS param. Si asignam
// un
loader al LayerNode i no li asignam un loader class, el
//
LayerParamLoader sera automaticament asumit.
loader:
{
param: "LAYERS"
}
},{
nodeType: "gx_layer",
layer:
"Material de la Canonada",
isLeaf:
false,
//
Crear subnodes dels layers en el LAYERS param. Si asignam
// un
loader al LayerNode i no li asignam un loader class, el
//
LayerParamLoader sera automaticament asumit.
loader:
{
param: "LAYERS"
}
},
], true);
tree = new Ext.tree.TreePanel({
border:
true,
region:
"east",
title:
"Capes Genèriques",
width:
218,
collapsible: true,
split:
true,
autoScroll: true,
loader:
new Ext.tree.TreeLoader({
// applyLoader a de ser posat a false per no interrumpir els
loaders
// dels nodes més avall a la gerarquia del Tree
applyLoader: false,
uiProviders: {
"layernodeui": LayerNodeUI
}
}),
root: {
nodeType: "gx_layer",
// Proveir el nombre inicial de layer nodes
children: Ext.decode(treeConfig)
},
rootVisible: false,
lines:
false,
});
treetema = new Ext.tree.TreePanel({
border:
true,
region:
"east",
title:
"Capes Tematiques",
width:
218,
collapsible: true,
split:
true,
autoScroll: true,
loader:
new Ext.tree.TreeLoader({
// applyLoader a de ser posat a false per no interrumpir els
loaders
// dels nodes més avall a la gerarquia del Tree
applyLoader: false,
uiProviders: {
"layernodeui": LayerNodeUItema
}
}),
root: {
nodeType: "gx_layer",
// Proveir el nombre inicial de layer nodes
children: Ext.decode(treeConfigtema)
},
rootVisible: false,
lines:
false,
});
var impanel = new Ext.form.FormPanel({
border: true,
title: "Impressio",
width: 218,
collapsible: true,
split: true,
autoScroll: true,
region: "east",
bodyStyle:
"padding:5px",
labelAlign: "top",
defaults: {anchor:
"100%"},
items: [{
xtype:
"textarea",
name: "comment",
value: "",
fieldLabel:
"Comment",
plugins: new
GeoExt.plugins.PrintPageField({
printPage: printPage
})
}, {
xtype: "combo",
store:
printProvider.layouts,
displayField:
"name",
fieldLabel:
"Layout",
typeAhead: true,
mode: "local",
triggerAction:
"all",
plugins: new
GeoExt.plugins.PrintProviderField({
printProvider: printProvider
})
}, {
xtype: "combo",
store:
printProvider.dpis,
displayField:
"name",
fieldLabel:
"Resolution",
tpl: '<tpl
for="."><div class="x-combo-list-item">{name}
dpi</div></tpl>',
typeAhead: true,
mode: "local",
triggerAction:
"all",
plugins: new
GeoExt.plugins.PrintProviderField({
printProvider: printProvider
}),
// the plugin
will work even if we modify a combo value
setValue:
function(v) {
v =
parseInt(v) + " dpi";
Ext.form.ComboBox.prototype.setValue.apply(this, arguments);
}
}, {
xtype: "combo",
store:
printProvider.scales,
displayField:
"name",
fieldLabel:
"Scale",
typeAhead: true,
mode: "local",
triggerAction:
"all",
plugins: new
GeoExt.plugins.PrintPageField({
printPage: printPage
})
}, {
xtype:
"textfield",
name:
"rotation",
fieldLabel:
"Rotation",
plugins: new
GeoExt.plugins.PrintPageField({
printPage: printPage
})
}],
buttons: [{
text: "Create
PDF",
handler:
function() {
printProvider.print(panel, printPage);
}
}]
});
var eastpanel= new Ext.Panel({
title: '',
region: 'east',
collapsible:
true,
split: true,
width: 220,
autoScroll:
true,
items:[tree,
treetema, legendPanel,impanel]
});
new Ext.Viewport({
layout: "fit",
hideBorders: false,
items: {
layout: "border",
deferredRender: false,
items: [panel,
eastpanel]
}
});
});*
--
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/PrintMap-with-Geoext-GeoServer-tp6904007p6904007.html
Sent from the GeoServer - User mailing list archive at Nabble.com.
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users
