source:
trunk/workshop-routing-foss4g/web/GeoExt/examples/print-preview-osm.js
@
77
Revision 76, 2.6 KB checked in by djay, 13 years ago (diff) | |
---|---|
|
Rev | Line | |
---|---|---|
[76] | 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-osm] | |
10 | * Printing OpenStreetMap | |
11 | * ---------------------------------------- | |
12 | * PrintMapPanel with an OSM map. | |
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 with OSM" | |
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 | -128 * 156543.0339, | |
36 | -128 * 156543.0339, | |
37 | 128 * 156543.0339, | |
38 | 128 * 156543.0339 | |
39 | ), | |
40 | maxResolution: 156543.0339, | |
41 | units: "m", | |
42 | projection: "EPSG:900913" | |
43 | }, | |
44 | layers: [new OpenLayers.Layer.OSM()], | |
45 | /*layers: [new OpenLayers.Layer.WMS("Tasmania State Boundaries", | |
46 | "http://demo.opengeo.org/geoserver/wms", | |
47 | {layers: "topp:tasmania_state_boundaries"}, {singleTile: true})],*/ | |
48 | center: [16314984.568391, -5095295.7603428], | |
49 | zoom: 6, | |
50 | bbar: [{ | |
51 | text: "Print...", | |
52 | handler: function(){ | |
53 | // A window with the PrintMapPanel, which we can use to adjust | |
54 | // the print extent before creating the pdf. | |
55 | printDialog = new Ext.Window({ | |
56 | title: "Print Preview", | |
57 | width: 350, | |
58 | autoHeight: true, | |
59 | items: [{ | |
60 | xtype: "gx_printmappanel", | |
61 | // use only a PanPanel control | |
62 | map: {controls: [new OpenLayers.Control.PanPanel()]}, | |
63 | sourceMap: mapPanel, | |
64 | printProvider: printProvider | |
65 | }], | |
66 | bbar: [{ | |
67 | text: "Create PDF", | |
68 | handler: function(){ printDialog.items.get(0).print(); } | |
69 | }] | |
70 | }); | |
71 | printDialog.show(); | |
72 | } | |
73 | }] | |
74 | }); | |
75 | ||
76 | }); |
Note: See TracBrowser
for help on using the repository browser.