Table Of Contents

Previous topic


Next topic



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.


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",
        {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() {

Config Options

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

OpenLayers.LonLat or Array(Number) A location for the map center. Do not set, as this will be overridden with the sourceMap center.
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 or or Array(OpenLayers.Layer) A store holding records. The layers provided here will be added to this MapPanel’s map when it is rendered.
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.
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.
Boolean Set this to true if you want pretty strings in the MapPanel’s state keys. More specifically, instead of 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 or Object PrintProvider to use for printing. If an Object is provided, a new PrintProvider will be created and configured with the object.


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, the capabilities must be loaded before PrintMapPanel initialization.

GeoExt.MapPanel or OpenLayers.Map The map that is to be printed.
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 A store containing objects.
OpenLayers.Map or Object A map or map configuration.
PrintMapPanel.previewScales 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 PrintPage for this PrintMapPanel. Read-only.
PrintMapPanel.printProvider PrintProvider for this PrintMapPanel.

Public Methods

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

Parameter:optionsObject options for the :: print method.

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