source:
trunk/workshop-routing-foss4g/web/GeoExt/examples/print-preview.js
@
77
Revision 76, 2.4 KB checked in by djay, 13 years ago (diff) | |
---|---|
|
Line | |
---|---|
1 | /** |
2 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
3 | * |
4 | * Published under the BSD license. |
5 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
6 | * of the license. |
7 | */ |
8 | |
9 | /** api: example[print-preview] |
10 | * Print Preview Window |
11 | * -------------------- |
12 | * Use the PrintMapPanel for interactive print previews. |
13 | */ |
14 | |
15 | var mapPanel, printDialog; |
16 | |
17 | Ext.onReady(function() { |
18 | // The PrintProvider that connects us to the print service |
19 | var printProvider = new GeoExt.data.PrintProvider({ |
20 | method: "GET", // "POST" recommended for production use |
21 | capabilities: printCapabilities, // provide url instead for lazy loading |
22 | customParams: { |
23 | mapTitle: "GeoExt Printing Demo", |
24 | comment: "This demo shows how to use GeoExt.PrintMapPanel" |
25 | } |
26 | }); |
27 | |
28 | // A MapPanel with a "Print..." button |
29 | mapPanel = new GeoExt.MapPanel({ |
30 | renderTo: "content", |
31 | width: 500, |
32 | height: 350, |
33 | map: { |
34 | maxExtent: new OpenLayers.Bounds( |
35 | 143.835, -43.648, |
36 | 148.479, -39.574 |
37 | ), |
38 | maxResolution: 0.018140625, |
39 | projection: "EPSG:4326", |
40 | units: 'degrees' |
41 | }, |
42 | layers: [new OpenLayers.Layer.WMS("Tasmania State Boundaries", |
43 | "http://demo.opengeo.org/geoserver/wms", |
44 | {layers: "topp:tasmania_state_boundaries"}, |
45 | {singleTile: true, numZoomLevels: 8})], |
46 | center: [146.56, -41.56], |
47 | zoom: 0, |
48 | bbar: [{ |
49 | text: "Print...", |
50 | handler: function(){ |
51 | // A window with the PrintMapPanel, which we can use to adjust |
52 | // the print extent before creating the pdf. |
53 | printDialog = new Ext.Window({ |
54 | title: "Print Preview", |
55 | layout: "fit", |
56 | width: 350, |
57 | autoHeight: true, |
58 | items: [{ |
59 | xtype: "gx_printmappanel", |
60 | sourceMap: mapPanel, |
61 | printProvider: printProvider |
62 | }], |
63 | bbar: [{ |
64 | text: "Create PDF", |
65 | handler: function(){ printDialog.items.get(0).print(); } |
66 | }] |
67 | }); |
68 | printDialog.show(); |
69 | } |
70 | }] |
71 | }); |
72 | |
73 | }); |
Note: See TracBrowser
for help on using the repository browser.