[Users] Vector layers and print preview

Andreas Hocevar ahocevar at opengeo.org
Sun Jan 15 00:10:34 CET 2012


Hi,

can you try if this patch solves the issue:

--- a/lib/GeoExt/widgets/PrintMapPanel.js
+++ b/lib/GeoExt/widgets/PrintMapPanel.js
@@ -193,7 +193,20 @@ GeoExt.PrintMapPanel = Ext.extend(GeoExt.MapPanel, {
         this.layers = [];
         var layer;
         Ext.each(this.sourceMap.layers, function(layer) {
-            layer.getVisibility() === true && this.layers.push(layer.clone());
+            if (layer.getVisibility() === true) {
+                if (layer instanceof OpenLayers.Vector) {
+                    var features = layer.features,
+                        clonedFeatures = new Array(features.length);
+                    for (var i=0, ii=features.length; i<ii; ++i) {
+                        clonedFeatures[i] = features[i].clone();
+                    }
+                    this.layers.push(new OpenLayers.Layer.Vector(layer.name, {
+                        features: clonedFeatures
+                    }));
+                } else {
+                    this.layers.push(layer.clone());
+                }
+            }
         }, this);

         this.extent = this.sourceMap.getExtent();

Andreas.

On Sat, Jan 14, 2012 at 11:02 PM, Alexandre Lessard
<alexandrel at solutionglobale.com> wrote:
> Hi again,
> Sorry for the lack of info.
>
> The printPreview uses the printMapPanel widget to create a copy of the
> source map,  the printMapPanel is initialized in the initComponent function
> of printPreview.js.
> . While doing the copy it uses the clone function of the layers.
>
> Here the printMapPanel code link at line 196 where there is the cloning :
> https://github.com/geoext/geoext/blob/master/lib/GeoExt/widgets/PrintMapPanel.js#L196
>
> Hope this is enough.
> Thanks Again
>
> Alexandre
>
>
> Le 2012-01-14 à 16:08, Andreas Hocevar a écrit :
>
> Hi,
>
> can you please enlighten me how
> http://trac.osgeo.org/openlayers/ticket/2749 relates to the Print
> Preview ux? To encode vector layers for printing, GeoExt does not
> clone them and also doesn't serialize properties other than features
> and styles, so I don't immediately see where that ticket could cause
> the Print Preview ux to not work.
>
> Andreas.
>
> On Fri, Jan 13, 2012 at 5:20 PM, Lessard Alexandre
> <alexandrel at solutionglobale.com> wrote:
>
> Hi everyone,
>
> I'm looking to use the "Print Preview" ux, but Someone told me that
>
> there was a big ticket about cloning vector layers with protocols and
>
> most of my vector layers have protocols. The ticket has already one year
>
> and a half and it's still not resolved, so I wanted to know if any of
>
> you have found a way around that problem?
>
>
> Here's the link to the openlayers ticket about the problem :
>
>
> http://trac.osgeo.org/openlayers/ticket/2749
>
>
> Thanks a lot!
>
>
> Alexandre Lessard
>
>
>
> _______________________________________________
>
> Users mailing list
>
> Users at geoext.org
>
> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>
>
>
>
> --
> Andreas Hocevar
> OpenGeo - http://opengeo.org/
> Expert service straight from the developers.
>
>



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.


More information about the Users mailing list