Hello all,<div><br></div><div>Just an update to the problems i was having.</div><div>Regarding the problem with layer ordering it was a programmatic mistake because i was using setLayerZindex method instead of setLayerIndex. Changing to this method solved the issue.</div>
<div><br></div><div>Regarding printing with legends but removing the vector layers from the request, i was able to achieve this, but not through an elegant way. Nevertheless it works. I created a fake GeoExt.LegendPanel and i remove the vector from this panel instead of the main panel through the following:</div>
<div><br></div><div>var legendPanel = new GeoExt.LegendPanel(...); //my main legend panel</div><div><br></div><div><div>var cloneLegLayerStore = new GeoExt.data.LayerStore();</div><div>var cloneLegPanel = new GeoExt.LegendPanel({</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>layerStore: cloneLegLayerStore</div><div>});</div></div><div><br></div><div>then, in the print button handler i do:</div><div><br></div><div><div>var legLayers = legendPanel.layerStore;</div>
<div>var cloneLegLayers = new Array();</div><div>legLayers.each(function(record){</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>var layerRec = record.get('layer');</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if (layerRec.CLASS_NAME == 'OpenLayers.Layer.WMS'){</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>cloneLegLayers.push(record);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div>});</div><div>cloneLegLayerStore.add(cloneLegLayers);</div>
<div><br></div><div>And with this, only my WMS layers legends are being printed.</div><div><br></div><div>Thanks a lot for all the comments and help, Geoffrey and Christian.</div><div>Cheers,</div><div><br></div><div>Hugo</div>
<br><div class="gmail_quote">On Fri, Oct 7, 2011 at 4:05 PM, gbrun <span dir="ltr"><<a href="mailto:gbrun@myopera.com">gbrun@myopera.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I would say, your legendPanel is not really cloned. In fact, the same javascript object relies upon your both variables ("legendPanel" and "cloneLegPanel"). It may exist a way allowing to really copy a javascript object and "paste" it in an other variable. In your case, it subsists a link between your two variables: when you modify the object represented by one of them, it also affects the other. Unfortunately, I don't know how to solve this problem. For layers, in GeoExt, it exists a "clone" function for the "LayerRecord" class that cleanly clones layers. It might be possible to do something similar with your legend.<br>
<br>
An other idea: if it doesn't work with the "beforeprint" function, you can try the "beforeencodelayer" function. In my app, I use this function to change layers url before they are printed (because of some problem with GeoWebCache layers). It works for layers: maybe there is a way to use this function for legend?<br>
<br>
Geoffrey<br>
<br>
<br>
<br>
Le Fri, 07 Oct 2011 16:38:25 +0200, Hugo <<a href="mailto:hfpmartins@gmail.com" target="_blank">hfpmartins@gmail.com</a>> a écrit:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div class="h5">
Hi,<br>
<br>
After testing a little bit more, i found that if i use this code in the<br>
beforeprint listener it still complains about the encoding itself. So, i<br>
moved this code to the handler of a print button before calling the print<br>
method. Using this approach it works somehow but it removes all my vector<br>
layers from the map. As you told, i have cloned the legendPanel (using<br>
Ext.apply) and still get the same issue, all my vector layers are gone.<br>
<br>
Here is the current code:<br>
<br>
var cloneLegPanel = {};<br>
Ext.apply(cloneLegPanel, legendPanel);<br>
var legLayerStore = cloneLegPanel.layerStore;<br>
legLayerStore.each(function(<u></u>record){<br>
var layerRec = record.get('layer');<br>
if (layerRec.CLASS_NAME == 'OpenLayers.Layer.Vector'){<br>
legLayerStore.remove(record);<br>
}<br>
});<br>
printProvider.print(mapPanel, printPage, {legend: cloneLegPanel});<br>
<br>
With this code i get the legends in the mapfish print pdf but i cannot print<br>
vector layers and they are removed from the map.<br>
What would you suggest? The thing i don't understand is why my vectors<br>
layers are being removed when i'm using a cloned object of the GeoExt Legend<br>
Panel. Any ideas?<br>
<br>
Thanks once again,<br>
Hugo<br>
<br>
On Fri, Oct 7, 2011 at 2:09 PM, gbrun <<a href="mailto:gbrun@myopera.com" target="_blank">gbrun@myopera.com</a>> wrote:<br>
<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div class="h5">
Hum, looking at your code, it might work! What does it happen with this<br>
code? Vector layers are completely removed from the map, not only from the<br>
legend panel? In this case, you should indeed clone your legend. Then, you<br>
could remove vector layers from this cloned legend. A the end, you can<br>
replace the old legend by the new one in your print function.<br>
<br>
I have never gone into this problem, so I have no ready-made solution! In<br>
my app, I have deactivated the "print legend" capabilities when a vector<br>
layer is contained in a map.<br>
<br>
Geoffrey<br>
<br>
<br>
<br>
Le Fri, 07 Oct 2011 14:49:34 +0200, Hugo <<a href="mailto:hfpmartins@gmail.com" target="_blank">hfpmartins@gmail.com</a>> a écrit:<br>
<br>
<br>
Hello Geoffrey,<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div class="h5">
<br>
Thanks a lot for your comments but my problem is exactly at destroying the<br>
legend printing for the vector layers. I have no idea on how to do this. I<br>
have tried the following but without success:<br>
<br>
beforeprint: function(printProv, printMap, printPages, printOpt){<br></div></div>
var includeLegend = Ext.getCmp('includeleg').**<u></u>getValue();<div class="im"><br>
if (includeLegend == true){<br>
var legOpt = printOpt.legend;<br>
var legLayerStore = legOpt.layerStore;<br></div>
legLayerStore.each(function(**<u></u>layerRec){<div class="im"><br>
var layerDef = layerRec.get('layer');<br>
if (layerDef.ClASS_NAME == 'OpenLayers.Layer.Vector'){<br></div>
legLayerStore.remove(layerRec)<u></u>**;<div><div></div><div class="h5"><br>
}<br>
})<br>
}<br>
}<br>
<br>
So my question would be, how can i tell the printprovider to not print the<br>
legend for this type of layers?<br>
<br>
Thanks a lot,<br>
Hugo<br>
<br>
On Fri, Oct 7, 2011 at 8:37 AM, gbrun <<a href="mailto:gbrun@myopera.com" target="_blank">gbrun@myopera.com</a>> wrote:<br>
<br>
Hi!<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div class="h5">
<br>
I would rather use the "beforeprint" or the "beforeencodelayer" function<br>
from the "printProvider" class. This function allows you to change some<br>
parameters before layers are printed. So, trough this function, you can<br>
test if your map contains vector layers. In this case, you can probably<br>
find a way to destroy their relative legend from the print process. You<br>
will find below an example:<br>
<br>
printProvider = new GeoExt.data.PrintProvider({<br>
method: 'POST', // 'POST' recommended for production use<br>
('GET' for<br>
development)<br>
capabilities: printCapabilities, // from the info.json<br>
script in the html<br>
listeners:{<br>
beforeprint: function(){<br>
// test each layer<br>
// if the layer is vector, remove<br>
it<br>
from the printed legend<br>
}, // or use the "beforeencodelayer" function<br>
beforeencodelayer: function (printProvider, layer){<br>
// test each layer (easy with the layer<br>
parameter provided by this<br>
function!)<br>
// if the layer is vector, remove<br>
it<br>
from the printed legend<br>
}<br>
}<br>
});<br>
<br>
I hope it might help you!<br>
<br>
Geoffrey<br>
<br>
<br>
Le Thu, 06 Oct 2011 20:17:20 +0200, Hugo <<a href="mailto:hfpmartins@gmail.com" target="_blank">hfpmartins@gmail.com</a>> a écrit:<br>
<br>
> Hello once again,<br>
><br>
> One more question though... If i still want to print legends without<br>
wfs<br>
> and<br>
> vector layers, how can i avoid these layers being passed in the<br>
request?<br>
><br>
> At the moment i have:<br>
> printProvider.print(mapPanel, printPage, {legend: legendPanel});<br>
><br>
> So i suppose i have to clone my legendPanel and set some properties for<br>
> the<br>
> layers i don't want to include in the legend. What would be the<br>
approach<br>
> to<br>
> follow?<br>
><br>
> Thanks,<br>
> Hugo<br>
><br>
> On Thu, Oct 6, 2011 at 2:48 PM, Hugo <<a href="mailto:hfpmartins@gmail.com" target="_blank">hfpmartins@gmail.com</a>> wrote:<br>
><br>
>> Hello Chris and Geoffrey,<br>
>><br>
>> Thanks a lot for your replies. I will look further into your<br>
suggestions<br>
>> and come back with feedback.<br>
>> Cheers,<br>
>><br>
>> Hugo<br>
>><br>
>><br>
>> On Tue, Oct 4, 2011 at 8:15 PM, Christian Mayer<br>
>> <<a href="mailto:mayer@terrestris.de" target="_blank">mayer@terrestris.de</a>>wrote:<br>
>><br>
>>> **<br>
>>> Hello Hugo,<br>
>>><br>
>>> for your second problem you may use the beforeprint event of the<br>
>>> PrintProvider class, with the<br>
>>> listener arguments:<br>
>>><br>
>>> - printProvider -<br>
>>> GeoExt.data.PrintProvider<<br>
</div></div><a href="http://geoext.org/lib/GeoExt/**data/PrintProvider.html#**" target="_blank">http://geoext.org/lib/GeoExt/*<u></u>*data/PrintProvider.html#**</a><div class="im"><br>
GeoExt.data.PrintProvider<<a href="http://geoext.org/lib/GeoExt/data/PrintProvider.html#GeoExt.data.PrintProvider" target="_blank">http<u></u>://geoext.org/lib/GeoExt/data/<u></u>PrintProvider.html#GeoExt.<u></u>data.PrintProvider</a>><br>
>this<br>
>>> PrintProvider<br>
>>> - map - OpenLayers.Map the map being printed<br>
>>> - pages - Array of<br>
>>> GeoExt.data.PrintPage<<br>
</div><a href="http://geoext.org/lib/GeoExt/**data/PrintPage.html#GeoExt.**" target="_blank">http://geoext.org/lib/GeoExt/*<u></u>*data/PrintPage.html#GeoExt.**</a><div class="im"><br>
data.PrintPage<<a href="http://geoext.org/lib/GeoExt/data/PrintPage.html#GeoExt.data.PrintPage" target="_blank">http://geoext.<u></u>org/lib/GeoExt/data/PrintPage.<u></u>html#GeoExt.data.PrintPage</a>><br>
>the<br>
>>> print pages being printed<br>
>>> - options - Object the options to the print command<br>
>>><br></div>
>>> see: <a href="http://geoext.org/lib/GeoExt/**data/PrintProvider.html" target="_blank">http://geoext.org/lib/GeoExt/*<u></u>*data/PrintProvider.html</a><<a href="http://geoext.org/lib/GeoExt/data/PrintProvider.html" target="_blank">http:<u></u>//geoext.org/lib/GeoExt/data/<u></u>PrintProvider.html</a>><div>
<div></div><div class="h5"><br>
>>><br>
>>> Maybe you check and rearrange your map object here.<br>
>>><br>
>>> Best regards,<br>
>>> Chris<br>
>>><br>
>>> Am 04.10.2011 19:58, schrieb gbrun:<br>
>>><br>
>>> Hi Hugo,<br>
>>><br>
>>> As far as I know, printing vector legend is not supported in the<br>
>>> current<br>
>>> GeoExt trunk.<br>
>>><br>
>>> No idea for your second problem!<br>
>>><br>
>>> Geoffrey<br>
>>><br>
>>><br>
>>> Le Tue, 04 Oct 2011 17:15:01 +0200, Hugo <<a href="mailto:hfpmartins@gmail.com" target="_blank">hfpmartins@gmail.com</a>><br>
>>> <<a href="mailto:hfpmartins@gmail.com" target="_blank">hfpmartins@gmail.com</a>> a écrit:<br>
>>><br>
>>><br>
>>> Hello all,<br>
>>><br>
>>> I was able to implement printing using printprovider, printpage and<br>
the<br>
>>> printextent plugin. However i have some small bugs which, untill now,<br>
i<br>
>>> wasn't able to solve.<br>
>>><br>
>>> The first problem i'm having is related with printing legends when<br>
>>> having<br>
>>> WFS layers on the map (firebuf is always showing: encFn is<br>
undefined).<br>
>>> I<br>
>>> have checked the encoders part of the prinProvider.js and in fact i<br>
>>> don't<br>
>>> see WFS there. However there is an encoder for vector layers. So my<br>
>>> first<br>
>>> question would be is it possible to print legends with WFS?<br>
>>><br>
>>> My second problem is related with layer order. When the app is<br>
loaded,<br>
>>> there<br>
>>> are some initial layers that are loaded (WMS, WFS and TileCache). I<br>
>>> also<br>
>>> have the functionality to allow user to add additional layers<br>
returned<br>
>>> by<br>
>>> WMS capabilities of geoserver. Because i wnated to keep all layers<br>
that<br>
>>> were<br>
>>> initially loaded above all others i'm setting layers ZIndex<br>
dynamically<br>
>>> in<br>
>>> the app. All is working fine when viewing and adding new layers (i<br>
>>> always<br>
>>> get inital loaded layers on top of the added ones). However, when<br>
>>> trying<br>
>>> to<br>
>>> print, the added layers from wms capabilities are always on the top<br>
of<br>
>>> all<br>
>>> others. More interesting is that, after printing, all layers are<br>
>>> magically<br>
>>> rearranged and in fact, the added layers become on top of all the<br>
>>> others.<br>
>>> What property am i missing here???<br>
>>><br>
>>> Kind regards,<br>
>>> Hugo<br>
>>><br>
>>><br></div></div>
>>> ______________________________<u></u>**_________________<br>
>>> Users mailing<br>
>>> listUsers@geoext.orghttp://<br>
<a href="http://www.geoext.org/cgi-bin/**mailman/listinfo/users" target="_blank">www.geoext.org/cgi-bin/**<u></u>mailman/listinfo/users</a><<a href="http://www.geoext.org/cgi-bin/mailman/listinfo/users" target="_blank">http://<u></u>www.geoext.org/cgi-bin/<u></u>mailman/listinfo/users</a>><div class="im">
<br>
>>><br>
>>><br>
>>><br>
>>> --<br>
>>> Dipl.-Ing.(FH) Christian Mayer<br>
>>> - Anwendungsentwickler -<br>
>>><br>
>>> terrestris GmbH & Co. KG<br>
>>> Irmintrudisstraße 17<br>
>>> 53111 Bonn<br>
>>><br>
>>> Tel: <a href="tel:%2B%2B49%20%280%29228%20%2F%2096%2028%2099%20-53" value="+4922896289953" target="_blank">++49 (0)228 / 96 28 99 -53</a><br>
>>> Fax: <a href="tel:%2B%2B49%20%280%29228%20%2F%2096%2028%2099%20-57" value="+4922896289957" target="_blank">++49 (0)228 / 96 28 99 -57</a><br>
>>><br>
>>> Email: <a href="mailto:mayer@terrestris.de" target="_blank">mayer@terrestris.de</a><br>
>>> Web: <a href="http://www.terrestris.de" target="_blank">http://www.terrestris.de</a><br>
>>><br>
>>> Amtsgericht Bonn, HRA 6835<br>
>>> Komplementärin: terrestris Verwaltungsgesellschaft mbH<br>
>>> vertreten durch: Hinrich Paulsen, Till Adams<br>
>>><br>
>>><br>
>>><br></div>
>>> ______________________________<u></u>**_________________<br>
>>> Users mailing list<br>
>>> <a href="mailto:Users@geoext.org" target="_blank">Users@geoext.org</a><br>
>>> <a href="http://www.geoext.org/cgi-bin/**mailman/listinfo/users" target="_blank">http://www.geoext.org/cgi-bin/<u></u>**mailman/listinfo/users</a><<a href="http://www.geoext.org/cgi-bin/mailman/listinfo/users" target="_blank">http:<u></u>//www.geoext.org/cgi-bin/<u></u>mailman/listinfo/users</a>><div class="im">
<br>
>>><br>
>>><br>
>><br>
>><br>
>> --<br>
>> Hugo Martins<br>
>> LabNT - ISEGI UNL<br>
>> Campus de Campolide<br>
>> 1070-312 Lisboa<br>
>> N 38°43'56.84", W 9°9'35.74"<br>
>><br>
><br>
><br>
><br>
<br>
<br>
--<br>
--<br>
Geoffrey BRUN<br>
<br>
Étudiant en master SIGMA<br>
Stagiaire au PNR du Haut-Languedoc<br>
<br>
Hameau de Brassac<br>
Saint-Pons de Thomières<br>
<a href="tel:%2B33%20%280%29%206%2077%2074%2044%2016" value="+33677744416" target="_blank">+33 (0) 6 77 74 44 16</a><br></div>
______________________________<u></u>**_________________<br>
Users mailing list<br>
<a href="mailto:Users@geoext.org" target="_blank">Users@geoext.org</a><br>
<a href="http://www.geoext.org/cgi-bin/**mailman/listinfo/users" target="_blank">http://www.geoext.org/cgi-bin/<u></u>**mailman/listinfo/users</a><<a href="http://www.geoext.org/cgi-bin/mailman/listinfo/users" target="_blank">http:<u></u>//www.geoext.org/cgi-bin/<u></u>mailman/listinfo/users</a>><br>
<br>
<br>
</blockquote>
<br>
<br>
<br>
</blockquote><div class="im">
<br>
--<br>
--<br>
Geoffrey BRUN<br>
<br>
Étudiant en master SIGMA<br>
Stagiaire au PNR du Haut-Languedoc<br>
<br>
Hameau de Brassac<br>
Saint-Pons de Thomières<br>
<a href="tel:%2B33%20%280%29%206%2077%2074%2044%2016" value="+33677744416" target="_blank">+33 (0) 6 77 74 44 16</a><br>
<br>
</div></blockquote>
<br>
<br>
<br>
</blockquote>
<br>
<br>
-- <br><div><div></div><div class="h5">
-- <br>
Geoffrey BRUN<br>
<br>
Étudiant en master SIGMA<br>
Stagiaire au PNR du Haut-Languedoc<br>
<br>
Hameau de Brassac<br>
Saint-Pons de Thomières<br>
<a href="tel:%2B33%20%280%29%206%2077%2074%2044%2016" value="+33677744416" target="_blank">+33 (0) 6 77 74 44 16</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Hugo Martins<br>LabNT - ISEGI UNL<br>Campus de Campolide<br>1070-312 Lisboa<br>N 38°43'56.84", W 9°9'35.74"<br>
</div>