[OpenLayers-Users] Mapfish/Geoserver print issues with GeoExt

Brad Bordine b.bordine at decapower.org
Wed Nov 27 16:45:18 PST 2013


I am trying to include a legend and a div containing some tabular data 
to the Geoserver print plug-in aka mapfish print. While I am having some 
issues with rendering my tiles from my remote server (the webapp 
co-hosted with  geoserver does not have this issue) my main concern is 
that the legend graphic is rendered as tiny, and because we have 
rule-based legends, a tiny icon will not work. The is a default scale 
argument in the documentation but I see no means to specify the scale to 
render the legend icons. I will include the yaml and some configuration 
code snippets.
//YAML
#===========================================================================
# allowed DPIs
#===========================================================================
dpis: [75, 150, 300]

#===========================================================================
# the allowed scales
#===========================================================================
scales:
   - 25000
   - 50000
   - 100000
   - 200000
   - 500000
   - 1000000
   - 2000000
   - 4000000

#===========================================================================
# the list of allowed hosts
#===========================================================================
hosts:
   - !localMatch
     dummy: true
   - !ipMatch
     ip: www.camptocamp.org
   - !dnsMatch
     host: labs.metacarta.com
     port: 80
   - !dnsMatch
     host: terraservice.net
     port: 80
   - !dnsMatch
     host: sigma.openplans.org
   - !dnsMatch
     host: demo.mapfish.org
   - !dnsMatch
     host: tile.stamen.com
   - !dnsMatch
     host: maps.openstreetmap.org
   - !dnsMatch
     host: www.decapower.org
   - !dnsMatch
     host: http://decapower.org
   - !dnsMatch
     host: maps.decapower.org
   - !dnsMatch
     host: http://server.arcgisonline.com

outputFilename: 'DecaMap'

layouts:
   Letter:
     mainPage:
       pageSize: LETTER
       items:
         - !map
           spacingAfter: 30
           width: 440
           height: 483
         - !legends
          backgroundColor: #FFFFFF
          borders: false
          horizontalAlignment: center
          maxWidth: 0
          maxHeight: 0
          iconMaxWidth: 0
          iconMaxHeight: 0
          iconPadding: 8 7 6 5
          textMaxWidth: 0
          textMaxHeight: 0
          textPadding: 8 7 6 5
          inline: true
          classIndentation: 10
          layerSpaceBefore: 5
          layerSpace: 5
          classSpace: 2
          layerFont: Helvetica
          layerFontSize: 10
          classFont: Helvetica
          classFontSize: 8
          fontEncoding: Cp1252
          columnMargin: 3
#===========================================================================
   A4 portrait:
#===========================================================================
     metaData:
#      title: '${mapTitle}'
       author: 'MapFish print module'
       subject: 'Simple layout'
       keywords: 'map,print'
       creator: 'MapFish'


#-------------------------------------------------------------------------
     mainPage:
       pageSize: A4
       rotation: true
       items:
         - !text
           text: '${mapTitle}'
           fontSize: 16
           spacingAfter: 30
         - !map
           spacingAfter: 30
           width: 440
           height: 483
         - !legends
          backgroundColor: #FFFFFF
          borders: false
          horizontalAlignment: left
          maxWidth: 0
          maxHeight: 0
          iconMaxWidth: 0
          iconMaxHeight: 0
          iconPadding: 8 7 6 5
          textMaxWidth: 0
          textMaxHeight:0
          textPadding: 8 7 6 5
          inline: true
          classIndentation: 5
          layerSpaceBefore: 5
          layerSpace: 5
          classSpace: 2
          layerFont: Helvetica
          layerFontSize: 10
          classFont: Helvetica
          classFontSize: 8
          fontEncoding: Cp1252
          columnMargin: 3

         - !columns
           # columns can have an absolute position. In that case, they 
need the 3 following fields:
           absoluteX: 410
           absoluteY: 310
           width: 100
           items:
             - !scalebar
               type: bar
               maxSize: 100
               barBgColor: white
               fontSize: 8
               align: right
         - !attributes
           source: data
           spacingAfter: 30
           columnDefs:
             id:
               columnWeight: 2
               header: !text
                 text: ID
                 backgroundColor: #A0A0A0
               cell: !text
                 text: '${id}'
             name:
               columnWeight: 5
               header: !text
                 text: Name
                 backgroundColor: #A0A0A0
               cell: !columns
                 config:
                   cells:
                     - backgroundColor: '${nameBackgroundColor}'
                       borderWidth: 1
                       borderColor: '${nameBorderColor}'
                 items:
                   - !text
                     text: '${name}'

           font: Helvetica
           fontSize: 9
           align: right
           text: '1:${scale} ${now MM.dd.yyyy}'

//-------------------------------------------------------------------------

//------ CODE FOR LEGEND ------->>
legendPanel = new GeoExt.LegendPanel({
         map: map,
         border : false,
         bodyStyle: 'background: transparent;',
         outputConfig: {autoScroll: true, autoHeight: true},
         defaults: {
//style: 'padding:5px',
                baseParams: {
                    LEGEND_OPTIONS: 
'forceLabels:on;fontName:SansSerif.plain;fontSize:9;'//
                    }
                }
});

//legend panel styling
new Ext.Panel({
         autoScroll: true,
         baseCls: 'legend_panel',
         title: "Legend",
         renderTo: 'legendpanel',
         bodyStyle: 'background: transparent;',
//    style: 'height: 100%',
         frame : false,
         header: false,
         border: false,
         draggable: false,
         collapsible: true,
//    padding: 10,
         items: legendPanel
});

// new 
snippet------------------------------------------------------------------
//------ CODE FOR PRINT BUTTON ------->>
var printPage;

var printProvider = new GeoExt.data.PrintProvider({
         method: "POST", // "POST" recommended for production use
         capabilities: printCapabilities, // from the info.json script 
in the html
         customParams: {
             mapTitle: "DECA Map",
             dpi: 300
         }
     });

printPage = new GeoExt.data.PrintPage({
         printProvider: printProvider,
         //scale: [100000]
     });

var includeLegend;



// new 
snippet------------------------------------------------------------------
// print button items on GeoExt panel
{
             text: "Print",
             handler: function() {
                 // convenient way to fit the print page to the visible 
map area
                 printPage.fit(mapPanel, true);
                 // print the page, optionally including the legend
                 printProvider.print(mapPanel, printPage, includeLegend 
&& {legend: legendPanel});
             }
         },
             {xtype: "checkbox",
             boxLabel: "Legend",
             handler: function() {includeLegend = this.checked}
             }
         ],


More information about the Users mailing list