[Users] Geox PrintExtent plugin + OpenLayers-2.11 line and polygon problem

Dariusz Górski darekgorski at o2.pl
Thu Sep 15 19:21:36 CEST 2011


Hello GeoExt list,

I use OpenLayers Editing Toolbar to draw features and Geoext PrintExtent 
plugin to print my vectors.
When I've used OpenLayers-2.10 all worked fine, but after upgrade to 
version 2.11 I'm getting an error while generating PDF if 
OpenLayers.Handler.Path or OpenLayers.Handler.Polygon is active.

Any suggestions?

Sample code:

<html>
<head>
<title>GeoExt PrintExtent Example</title>

<script type="text/javascript" 
src="http://extjs.cachefly.net/ext-3.2.1/adapter/ext/ext-base.js"></script>
<script type="text/javascript" 
src="http://extjs.cachefly.net/ext-3.2.1/ext-all.js"></script>
<link rel="stylesheet" type="text/css" 
href="http://extjs.cachefly.net/ext-3.2.1/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" 
href="http://extjs.cachefly.net/ext-3.2.1/examples/shared/examples.css" />
<script src="http://www.openlayers.org/api/2.11/OpenLayers.js"></script>
<script type="text/javascript" src="../lib/GeoExt.js"></script>
<script type="text/javascript" 
src="http://demo.opengeo.org/geoserver/pdf/info.json?var=printCapabilities"></script>

<script type="text/javascript">
         var mapPanel, printProvider;

         Ext.onReady(function() {
             // The printProvider that connects us to the print service
             printProvider = new GeoExt.data.PrintProvider({
                 method: "GET", // "POST" recommended for production use
                 capabilities: printCapabilities, // from the info.json 
script in the html
                 customParams: {
                     mapTitle: "Printing Demo",
                     comment: "This is a map printed from GeoExt."
                 }
             });

             var printExtent = new GeoExt.plugins.PrintExtent({
                 printProvider: printProvider
             });

             layer = new OpenLayers.Layer.WMS("Tasmania", 
"http://demo.opengeo.org/geoserver/wms",
                     {layers: "topp:tasmania_state_boundaries"}, 
{singleTile: true});

                         vlayer = new OpenLayers.Layer.Vector( "Editable" );
                         map = new OpenLayers.Map( 'map', {
                             controls: [
                                 new OpenLayers.Control.PanZoom(),
                                 new 
OpenLayers.Control.EditingToolbar(vlayer)
                             ]
                         });
                         map.addLayers([layer, vlayer]);

             // The map we want to print, with the PrintExtent added as 
item.
             mapPanel = new GeoExt.MapPanel({
                 renderTo: "content",
                 width: 450,
                 height: 320,
                 map: map,
                 center: [146.56, -41.56],
                 zoom: 6,
                 plugins: [printExtent],
                 bbar: [{
                     text: "Create PDF",
                     handler: function() {
                         // the PrintExtent plugin is the mapPanel's 1st 
plugin
                         mapPanel.plugins[0].print();
                     }
                 }]
             });
             printExtent.addPage();
         });
</script>

</head>
<body>
<div id="content"></div>
</body>
</html>

Regards,
Darek



More information about the Users mailing list