Hello Geoffrey,<div><br></div><div>Thanks a lot for your comments but my problem is exactly at destroying the legend printing for the vector layers. I have no idea on how to do this. I have tried the following but without success:</div>
<div><br></div><div><div>beforeprint: function(printProv, printMap, printPages, printOpt){</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>var includeLegend = Ext.getCmp('includeleg').getValue();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>if (includeLegend == true){</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>var legOpt = printOpt.legend;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>var legLayerStore = legOpt.layerStore;</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>legLayerStore.each(function(layerRec){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>var layerDef = layerRec.get('layer');</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>if (layerDef.ClASS_NAME == 'OpenLayers.Layer.Vector'){</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>legLayerStore.remove(layerRec);</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>})</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div>
<div>}</div><div><br></div><div>So my question would be, how can i tell the printprovider to not print the legend for this type of layers?</div><div><br></div><div>Thanks a lot,</div><div>Hugo</div><br><div class="gmail_quote">
On Fri, Oct 7, 2011 at 8:37 AM, 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;">
Hi!<br>
<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 ('GET' for<br>
development)<br>
capabilities: printCapabilities, // from the info.json script in the html<br>
listeners:{<br>
beforeprint: function(){<br>
// test each layer<br>
// if the layer is vector, remove it from the printed legend<br>
}, // or use the "beforeencodelayer" function<br>
beforeencodelayer: function (printProvider, layer){<br>
// test each layer (easy with the layer parameter provided by this<br>
function!)<br>
// if the layer is vector, remove it 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">hfpmartins@gmail.com</a>> a écrit:<br>
<div class="im"><br>
> Hello once again,<br>
><br>
> One more question though... If i still want to print legends without wfs<br>
> and<br>
> vector layers, how can i avoid these layers being passed in the 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 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">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 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">mayer@terrestris.de</a>>wrote:<br>
>><br>
</div>>>> **<br>
<div class="im">>>> 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>
</div>>>> - printProvider -<br>
>>> GeoExt.data.PrintProvider<<a href="http://geoext.org/lib/GeoExt/data/PrintProvider.html#GeoExt.data.PrintProvider" target="_blank">http://geoext.org/lib/GeoExt/data/PrintProvider.html#GeoExt.data.PrintProvider</a>>this<br>
>>> PrintProvider<br>
>>> - map - OpenLayers.Map the map being printed<br>
>>> - pages - Array of<br>
>>> GeoExt.data.PrintPage<<a href="http://geoext.org/lib/GeoExt/data/PrintPage.html#GeoExt.data.PrintPage" target="_blank">http://geoext.org/lib/GeoExt/data/PrintPage.html#GeoExt.data.PrintPage</a>>the<br>
>>> print pages being printed<br>
>>> - options - Object the options to the print command<br>
<div><div></div><div class="h5">>>><br>
>>> see: <a href="http://geoext.org/lib/GeoExt/data/PrintProvider.html" target="_blank">http://geoext.org/lib/GeoExt/data/PrintProvider.html</a><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">hfpmartins@gmail.com</a>><br>
>>> <<a href="mailto:hfpmartins@gmail.com">hfpmartins@gmail.com</a>> a écrit:<br>
>>><br>
>>><br>
>>> Hello all,<br>
>>><br>
>>> I was able to implement printing using printprovider, printpage and the<br>
>>> printextent plugin. However i have some small bugs which, untill now, 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 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 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 returned<br>
>>> by<br>
>>> WMS capabilities of geoserver. Because i wnated to keep all layers that<br>
>>> were<br>
>>> initially loaded above all others i'm setting layers ZIndex 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 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>
>>> _______________________________________________<br>
>>> Users mailing<br>
</div></div>>>> listUsers@geoext.orghttp://<a href="http://www.geoext.org/cgi-bin/mailman/listinfo/users" target="_blank">www.geoext.org/cgi-bin/mailman/listinfo/users</a><br>
<div class="im">>>><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">++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">++49 (0)228 / 96 28 99 -57</a><br>
>>><br>
>>> Email: <a href="mailto:mayer@terrestris.de">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>
>>> _______________________________________________<br>
>>> Users mailing list<br>
>>> <a href="mailto:Users@geoext.org">Users@geoext.org</a><br>
>>> <a href="http://www.geoext.org/cgi-bin/mailman/listinfo/users" target="_blank">http://www.geoext.org/cgi-bin/mailman/listinfo/users</a><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>
</div><font color="#888888">--<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">+33 (0) 6 77 74 44 16</a><br>
</font><div><div></div><div class="h5">_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@geoext.org">Users@geoext.org</a><br>
<a href="http://www.geoext.org/cgi-bin/mailman/listinfo/users" target="_blank">http://www.geoext.org/cgi-bin/mailman/listinfo/users</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>