GeoExt

Table Of Contents

Previous topic

GeoExt.Popup

Next topic

GeoExt.UrlLegend

GeoExt.PrintMapPanel

Extends
xtype
gx_printmappanel
class GeoExt.PrintMapPanel

A map panel that controls scale and center of a print page. Based on the current view (i.e. layers and extent) of a source map, this panel will be sized according to the aspect ratio of the print page. As the user zooms and pans in the GeoExt.PrintMapPanel, the print page will update its scale and center accordingly. If the scale on the print page changes (e.g. by setting it using a combo box with a GeoExt.plugins.PrintPageField), the extent of the GeoExt.PrintMapPanel will be updated to match the page bounds.

Note

The zoom, center and extent config options will have no affect, as they will be determined by the sourceMap.

Example Use

A map with a “Print...” button. If clicked, a dialog containing a PrintMapPanel will open, with a “Create PDF” button.

var mapPanel = new GeoExt.MapPanel({
    renderTo: "map",
    layers: [new OpenLayers.Layer.WMS("Tasmania State Boundaries",
        "http://demo.opengeo.org/geoserver/wms",
        {layers: "topp:tasmania_state_boundaries"}, {singleTile: true})],
    center: [146.56, -41.56],
    zoom: 6,
    bbar: [{
        text: "Print...",
        handler: function() {
            var printDialog = new Ext.Window({
                autoHeight: true,
                width: 350,
                items: [new GeoExt.PrintMapPanel({
                    sourceMap: mapPanel,
                    printProvider: {
                        capabilities: printCapabilities
                    }
                })],
                bbar: [{
                    text: "Create PDF",
                    handler: function() {
                        printDialog.items.get(0).print();
                    }
                }]
            });
            printDialog.show();
        }
    }]
});

Config Options

Configuration properties in addition to those listed for Ext.Panel.

center
OpenLayers.LonLat or Array(Number) A location for the map center. Do not set, as this will be overridden with the sourceMap center.
extent
OpenLayers.Bounds or Array(Number) An initial extent for the map. Do not set, because the initial extent will be determined by the sourceMap.
layers
GeoExt.data.LayerStore or GeoExt.data.GroupingStore or Array(OpenLayers.Layer) A store holding records. The layers provided here will be added to this MapPanel’s map when it is rendered.
limitScales
Boolean If set to true, the printPage cannot be set to scales that would generate a preview in this GeoExt.PrintMapPanel with a completely different extent than the one that would appear on the printed map. Default is false.
map
Object Optional configuration for the OpenLayers.Map object that this PrintMapPanel creates. Useful e.g. to configure a map with a custom set of controls, or to add a preaddlayer listener for filtering out layer types that cannot be printed.
prettyStateKeys
Boolean Set this to true if you want pretty strings in the MapPanel’s state keys. More specifically, layer.name instead of layer.id will be used in the state keys if this option is set to true. But in that case you have to make sure you don’t have two layers with the same name. Defaults to false.
printProvider

GeoExt.data.PrintProvider or Object PrintProvider to use for printing. If an Object is provided, a new PrintProvider will be created and configured with the object.

Note

The PrintMapPanel requires the printProvider’s capabilities to be available upon initialization. This means that a PrintMapPanel configured with an Object as printProvider will only work when capabilities is provided in the printProvider’s configuration object. If printProvider is provided as an instance of GeoExt.data.PrintProvider, the capabilities must be loaded before PrintMapPanel initialization.

sourceMap
GeoExt.MapPanel or OpenLayers.Map The map that is to be printed.
zoom
Number An initial zoom level for the map. Do not set, because the initial extent will be determined by the sourceMap.

Public Properties

Public properties in addition to those listed for Ext.Panel.

PrintMapPanel.layers
GeoExt.data.LayerStore A store containing GeoExt.data.LayerRecord objects.
PrintMapPanel.map
OpenLayers.Map or Object A map or map configuration.
PrintMapPanel.previewScales
Ext.data.Store A data store with a subset of the printProvider’s scales. By default, this contains all the scales of the printProvider. If limitScales is set to true, it will only contain print scales that can properly be previewed with this GeoExt.PrintMapPanel.
PrintMapPanel.printPage
GeoExt.data.PrintPage PrintPage for this PrintMapPanel. Read-only.
PrintMapPanel.printProvider
GeoExt.data.PrintProvider PrintProvider for this PrintMapPanel.

Public Methods

Public methods in addition to those listed for Ext.Panel.

PrintMapPanel.print()
Parameter:optionsObject options for the GeoExt.data.PrintProvider :: print method.

Convenience method for printing the map, without the need to interact with the printProvider and printPage.