[Users] Vector layers and print preview

62 views
Skip to first unread message

Lessard Alexandre

unread,
Jan 13, 2012, 11:20:47 AM1/13/12
to us...@geoext.org
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
Us...@geoext.org
http://www.geoext.org/cgi-bin/mailman/listinfo/users

Andreas Hocevar

unread,
Jan 14, 2012, 4:08:38 PM1/14/12
to Lessard Alexandre, us...@geoext.org
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.

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

Andreas Hocevar

unread,
Jan 14, 2012, 6:10:34 PM1/14/12
to Alexandre Lessard, us...@geoext.org
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
<alexa...@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

Alexandre Dube

unread,
Mar 16, 2012, 11:49:23 AM3/16/12
to us...@geoext.org
Andreas,

I tried and updated your patch a little. It solves the issue for
me. See :
https://github.com/geoext/geoext/pull/33

Regards,

Alexandre


On 12-01-14 06:10 PM, Andreas Hocevar wrote:
> 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());


--
Alexandre Dubé
Mapgears
www.mapgears.com

Dan Ramage

unread,
Apr 3, 2012, 12:32:19 PM4/3/12
to us...@geoext.org
All,

I'm in the process of updating to GeoExt1.1, ExtJS3.4 and OL2.11. I'm
running into an issue that I think I've pinned down to something with my
layer tree. Basically, the base map, Google in this case, is not tiling
correctly. I have some vector features that seem to show up properly,
however the basemap is off. It's almost as if they projections between the 2
are off. If I disable the layer tree generation, the map works properly. My
test map is here: http://rcoos.org/carolinasrcoosrev2/indexDebug2.php
Although I am not sure if this is the same issue, the GeoExt example:
http://api.geoext.org/1.1/examples/tree.html does not work properly either,
the tiling is incorrect.

Was wondering if anyone experienced anything similar.

Thanks!

Dan

Ralph Dell

unread,
Apr 3, 2012, 1:15:49 PM4/3/12
to Dan Ramage, us...@geoext.org
Well I almost hate to say this but I am not seeing a problem, it is
possible I misunderstood you.
I have tried two different browsers, FF and IE9, and had the google
hybrid and terrain layers off and on at various scales, as well as some
vector layers. I did not see the problem that does show up on the geoext
example.

Reading your post again are you saying some of your vectors are off
relative to the google layers?

Ralph Dell

Dan Ramage

unread,
Apr 3, 2012, 2:17:02 PM4/3/12
to us...@geoext.org
I fixed the issue, although I am not sure why it was not working or why it
affected the map panel.
My tree node creation was similar to this:
Node = {
id: layer.options.GROUP,
cls: 'layer-tree-node',
text: layer.options.GROUP,
nodeType: "gx_layercontainer",
expanded: nodeExpanded,

loader: new GeoExt.tree.layerLoaderExtended(
{
baseAttrs:
{
group: layer.options.GROUP
},
filter: this.displayLayerInGroup,
})
}
I changed it to actually create the object:
var node = new GeoExt.tree.LayerContainer({.....})

Now the base map tiles are aligning correctly.

The GeoExt tree example creates the nodes similarly to the way I was
creating them, and it has a basemap issue as well. Not sure if it is the
same one I had or not.


Dan


-----Original Message-----
From: Dan Ramage [mailto:d...@inlet.geol.sc.edu]
Sent: Tuesday, April 03, 2012 12:32 PM
To: 'us...@geoext.org'
Subject: Layer Tree Issues Upagrading to GeoExt v1.1

All,

I'm in the process of updating to GeoExt1.1, ExtJS3.4 and OL2.11. I'm
running into an issue that I think I've pinned down to something with my
layer tree. Basically, the base map, Google in this case, is not tiling
correctly. I have some vector features that seem to show up properly,
however the basemap is off. It's almost as if they projections between the 2
are off. If I disable the layer tree generation, the map works properly. My
test map is here: http://rcoos.org/carolinasrcoosrev2/indexDebug2.php
Although I am not sure if this is the same issue, the GeoExt example:
http://api.geoext.org/1.1/examples/tree.html does not work properly either,
the tiling is incorrect.

Was wondering if anyone experienced anything similar.

Thanks!

Dan

_______________________________________________

Dan Ramage

unread,
Apr 3, 2012, 3:14:44 PM4/3/12
to Ralph Dell, us...@geoext.org
Ralph,

I think I solved it. I've sent another group email detailing what I found.
Did you look at the GeoExt
example(http://api.geoext.org/1.1/examples/tree.html) to see if that one
worked for you?

Dan

Reply all
Reply to author
Forward
0 new messages