Hi,<div><br></div><div>After testing a little bit more, i found that if i use this code in the beforeprint listener it still complains about the encoding itself. So, i moved this code to the handler of a print button before calling the print method. Using this approach it works somehow but it removes all my vector layers from the map. As you told, i have cloned the legendPanel (using Ext.apply) and still get the same issue, all my vector layers are gone.</div>
<div><br></div><div>Here is the current code:</div><div><br></div><div><div>var cloneLegPanel = {};</div><div>Ext.apply(cloneLegPanel, legendPanel);</div><div>var legLayerStore = cloneLegPanel.layerStore;</div><div>legLayerStore.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.Vector'){</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>legLayerStore.remove(record);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div>});</div><div>printProvider.print(mapPanel, printPage, {legend: cloneLegPanel});</div>
<div><br></div><div>With this code i get the legends in the mapfish print pdf but i cannot print vector layers and they are removed from the map.</div><div>What would you suggest? The thing i don't understand is why my vectors layers are being removed when i'm using a cloned object of the GeoExt Legend Panel. Any ideas?</div>
<div><br></div><div>Thanks once again,</div><div>Hugo</div><br><div class="gmail_quote">On Fri, Oct 7, 2011 at 2:09 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;">Hum, looking at your code, it might work! What does it happen with this code? Vector layers are completely removed from the map, not only from the legend panel? In this case, you should indeed clone your legend. Then, you could remove vector layers from this cloned legend. A the end, you can 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 my app, I have deactivated the "print legend" capabilities when a vector 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:<div><div></div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello Geoffrey,<br>
<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>
var includeLegend = Ext.getCmp('includeleg').<u></u>getValue();<br>
if (includeLegend == true){<br>
var legOpt = printOpt.legend;<br>
var legLayerStore = legOpt.layerStore;<br>
legLayerStore.each(function(<u></u>layerRec){<br>
var layerDef = layerRec.get('layer');<br>
if (layerDef.ClASS_NAME == 'OpenLayers.Layer.Vector'){<br>
legLayerStore.remove(layerRec)<u></u>;<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>
<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<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 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 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 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" 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 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>
<a href="http://geoext.org/lib/GeoExt/data/PrintProvider.html#GeoExt.data.PrintProvider" target="_blank">http://geoext.org/lib/GeoExt/<u></u>data/PrintProvider.html#<u></u>GeoExt.data.PrintProvider</a><br>
>this<br>
>>> PrintProvider<br>
>>> - map - OpenLayers.Map the map being printed<br>
>>> - pages - Array of<br>
>>> GeoExt.data.PrintPage<<br>
<a href="http://geoext.org/lib/GeoExt/data/PrintPage.html#GeoExt.data.PrintPage" target="_blank">http://geoext.org/lib/GeoExt/<u></u>data/PrintPage.html#GeoExt.<u></u>data.PrintPage</a>>the<br>
>>> print pages being printed<br>
>>> - options - Object the options to the print command<br>
>>><br>
>>> see: <a href="http://geoext.org/lib/GeoExt/data/PrintProvider.html" target="_blank">http://geoext.org/lib/GeoExt/<u></u>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" 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 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>
>>> ______________________________<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><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>
>>> ______________________________<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><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>
______________________________<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><br>
<br>
</blockquote>
<br>
<br>
<br>
</blockquote>
<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></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>