Thanks for this return, for sure it would be useful in the future for some  
people!


Le Wed, 12 Oct 2011 18:03:55 +0200, Hugo <hfpmart...@gmail.com> a écrit:

> Hello all,
>
> Just an update to the problems i was having.
> 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.
>
> 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:
>
> var legendPanel = new GeoExt.LegendPanel(...); //my main legend panel
>
> var cloneLegLayerStore = new GeoExt.data.LayerStore();
> var cloneLegPanel = new GeoExt.LegendPanel({
> layerStore: cloneLegLayerStore
> });
>
> then, in the print button handler i do:
>
> var legLayers = legendPanel.layerStore;
> var cloneLegLayers = new Array();
> legLayers.each(function(record){
> var layerRec = record.get('layer');
> if (layerRec.CLASS_NAME == 'OpenLayers.Layer.WMS'){
> cloneLegLayers.push(record);
> }
> });
> cloneLegLayerStore.add(cloneLegLayers);
>
> And with this, only my WMS layers legends are being printed.
>
> Thanks a lot for all the comments and help, Geoffrey and Christian.
> Cheers,
>
> Hugo
>
> On Fri, Oct 7, 2011 at 4:05 PM, gbrun <gb...@myopera.com> wrote:
>
>> 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.
>>
>> 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?
>>
>> Geoffrey
>>
>>
>>
>> Le Fri, 07 Oct 2011 16:38:25 +0200, Hugo <hfpmart...@gmail.com> a écrit:
>>
>>  Hi,
>>>
>>> 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.
>>>
>>> Here is the current code:
>>>
>>> var cloneLegPanel = {};
>>> Ext.apply(cloneLegPanel, legendPanel);
>>> var legLayerStore = cloneLegPanel.layerStore;
>>> legLayerStore.each(function(**record){
>>> var layerRec = record.get('layer');
>>> if (layerRec.CLASS_NAME == 'OpenLayers.Layer.Vector'){
>>> legLayerStore.remove(record);
>>> }
>>> });
>>> printProvider.print(mapPanel, printPage, {legend: cloneLegPanel});
>>>
>>> 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.
>>> 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?
>>>
>>> Thanks once again,
>>> Hugo
>>>
>>> On Fri, Oct 7, 2011 at 2:09 PM, gbrun <gb...@myopera.com> wrote:
>>>
>>>  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.
>>>>
>>>> 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.
>>>>
>>>> Geoffrey
>>>>
>>>>
>>>>
>>>> Le Fri, 07 Oct 2011 14:49:34 +0200, Hugo <hfpmart...@gmail.com> a  
>>>> écrit:
>>>>
>>>>
>>>>  Hello Geoffrey,
>>>>
>>>>>
>>>>> 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:
>>>>>
>>>>> beforeprint: function(printProv, printMap, printPages, printOpt){
>>>>> var includeLegend = Ext.getCmp('includeleg').****getValue();
>>>>>
>>>>> if (includeLegend == true){
>>>>> var legOpt = printOpt.legend;
>>>>> var legLayerStore = legOpt.layerStore;
>>>>> legLayerStore.each(function(****layerRec){
>>>>>
>>>>> var layerDef = layerRec.get('layer');
>>>>> if (layerDef.ClASS_NAME == 'OpenLayers.Layer.Vector'){
>>>>> legLayerStore.remove(layerRec)****;
>>>>>
>>>>> }
>>>>> })
>>>>> }
>>>>> }
>>>>>
>>>>> So my question would be, how can i tell the printprovider to not  
>>>>> print
>>>>> the
>>>>> legend for this type of layers?
>>>>>
>>>>> Thanks a lot,
>>>>> Hugo
>>>>>
>>>>> On Fri, Oct 7, 2011 at 8:37 AM, gbrun <gb...@myopera.com> wrote:
>>>>>
>>>>>  Hi!
>>>>>
>>>>>>
>>>>>> I would rather use the "beforeprint" or the "beforeencodelayer"
>>>>>> function
>>>>>>  from the "printProvider" class. This function allows you to change
>>>>>> some
>>>>>> parameters before layers are printed. So, trough this function, you  
>>>>>> can
>>>>>> test if your map contains vector layers. In this case, you can  
>>>>>> probably
>>>>>> find a way to destroy their relative legend from the print process.  
>>>>>> You
>>>>>> will find below an example:
>>>>>>
>>>>>>      printProvider = new GeoExt.data.PrintProvider({
>>>>>>              method: 'POST', // 'POST' recommended for production  
>>>>>> use
>>>>>> ('GET' for
>>>>>> development)
>>>>>>              capabilities: printCapabilities, // from the info.json
>>>>>> script in the html
>>>>>>              listeners:{
>>>>>>                      beforeprint: function(){
>>>>>>                              // test each layer
>>>>>>                                      // if the layer is vector,  
>>>>>> remove
>>>>>> it
>>>>>> from the printed legend
>>>>>>                      }, // or use the "beforeencodelayer" function
>>>>>>                      beforeencodelayer: function (printProvider,
>>>>>> layer){
>>>>>>                              // test each layer (easy with the layer
>>>>>> parameter provided by this
>>>>>> function!)
>>>>>>                                      // if the layer is vector,  
>>>>>> remove
>>>>>> it
>>>>>> from the printed legend
>>>>>>                      }
>>>>>>              }
>>>>>>      });
>>>>>>
>>>>>> I hope it might help you!
>>>>>>
>>>>>> Geoffrey
>>>>>>
>>>>>>
>>>>>> Le Thu, 06 Oct 2011 20:17:20 +0200, Hugo <hfpmart...@gmail.com> a
>>>>>> écrit:
>>>>>>
>>>>>> > Hello once again,
>>>>>> >
>>>>>> > One more question though... If i still want to print legends  
>>>>>> without
>>>>>> wfs
>>>>>> > and
>>>>>> > vector layers, how can i avoid these layers being passed in the
>>>>>> request?
>>>>>> >
>>>>>> > At the moment i have:
>>>>>> > printProvider.print(mapPanel, printPage, {legend: legendPanel});
>>>>>> >
>>>>>> > So i suppose i have to clone my legendPanel and set some  
>>>>>> properties
>>>>>> for
>>>>>> > the
>>>>>> > layers i don't want to include in the legend. What would be the
>>>>>> approach
>>>>>> > to
>>>>>> > follow?
>>>>>> >
>>>>>> > Thanks,
>>>>>> > Hugo
>>>>>> >
>>>>>> > On Thu, Oct 6, 2011 at 2:48 PM, Hugo <hfpmart...@gmail.com> wrote:
>>>>>> >
>>>>>> >> Hello Chris and Geoffrey,
>>>>>> >>
>>>>>> >> Thanks a lot for your replies. I will look further into your
>>>>>> suggestions
>>>>>> >> and come back with feedback.
>>>>>> >> Cheers,
>>>>>> >>
>>>>>> >> Hugo
>>>>>> >>
>>>>>> >>
>>>>>> >> On Tue, Oct 4, 2011 at 8:15 PM, Christian Mayer
>>>>>> >> <ma...@terrestris.de>wrote:
>>>>>> >>
>>>>>> >>> **
>>>>>> >>> Hello Hugo,
>>>>>> >>>
>>>>>> >>> for your second problem you may use the beforeprint event of the
>>>>>> >>> PrintProvider class, with the
>>>>>> >>> listener arguments:
>>>>>> >>>
>>>>>> >>>    - printProvider -
>>>>>> >>> GeoExt.data.PrintProvider<
>>>>>> http://geoext.org/lib/GeoExt/****data/PrintProvider.html#**<http://geoext.org/lib/GeoExt/**data/PrintProvider.html#**>
>>>>>>
>>>>>> GeoExt.data.PrintProvider<http**://geoext.org/lib/GeoExt/data/**
>>>>>> PrintProvider.html#GeoExt.**data.PrintProvider<http://geoext.org/lib/GeoExt/data/PrintProvider.html#GeoExt.data.PrintProvider>
>>>>>> >
>>>>>> >this
>>>>>> >>> PrintProvider
>>>>>> >>>    - map - OpenLayers.Map the map being printed
>>>>>> >>>    - pages - Array of
>>>>>> >>> GeoExt.data.PrintPage<
>>>>>> http://geoext.org/lib/GeoExt/****data/PrintPage.html#GeoExt.**<http://geoext.org/lib/GeoExt/**data/PrintPage.html#GeoExt.**>
>>>>>>
>>>>>> data.PrintPage<http://geoext.**org/lib/GeoExt/data/PrintPage.**
>>>>>> html#GeoExt.data.PrintPage<http://geoext.org/lib/GeoExt/data/PrintPage.html#GeoExt.data.PrintPage>
>>>>>> >
>>>>>> >the
>>>>>> >>> print pages being printed
>>>>>> >>>    - options - Object the options to the print command
>>>>>> >>>
>>>>>> >>> see:  
>>>>>> http://geoext.org/lib/GeoExt/****data/PrintProvider.html<http://geoext.org/lib/GeoExt/**data/PrintProvider.html>
>>>>>> <http:**//geoext.org/lib/GeoExt/data/**PrintProvider.html<http://geoext.org/lib/GeoExt/data/PrintProvider.html>
>>>>>> >
>>>>>>
>>>>>> >>>
>>>>>> >>> Maybe you check and rearrange your map object here.
>>>>>> >>>
>>>>>> >>> Best regards,
>>>>>> >>> Chris
>>>>>> >>>
>>>>>> >>> Am 04.10.2011 19:58, schrieb gbrun:
>>>>>> >>>
>>>>>> >>> Hi Hugo,
>>>>>> >>>
>>>>>> >>> As far as I know, printing vector legend is not supported in the
>>>>>> >>> current
>>>>>> >>> GeoExt trunk.
>>>>>> >>>
>>>>>> >>> No idea for your second problem!
>>>>>> >>>
>>>>>> >>> Geoffrey
>>>>>> >>>
>>>>>> >>>
>>>>>> >>> Le Tue, 04 Oct 2011 17:15:01 +0200, Hugo <hfpmart...@gmail.com>
>>>>>> >>> <hfpmart...@gmail.com> a écrit:
>>>>>> >>>
>>>>>> >>>
>>>>>> >>>  Hello all,
>>>>>> >>>
>>>>>> >>> I was able to implement printing using printprovider, printpage  
>>>>>> and
>>>>>> the
>>>>>> >>> printextent plugin. However i have some small bugs which, untill
>>>>>> now,
>>>>>> i
>>>>>> >>> wasn't able to solve.
>>>>>> >>>
>>>>>> >>> The first problem i'm having is related with printing legends  
>>>>>> when
>>>>>> >>> having
>>>>>> >>> WFS layers on the map (firebuf is always showing: encFn is
>>>>>> undefined).
>>>>>> >>> I
>>>>>> >>> have checked the encoders part of the prinProvider.js and in  
>>>>>> fact i
>>>>>> >>> don't
>>>>>> >>> see WFS there. However there is an encoder for vector layers.  
>>>>>> So my
>>>>>> >>> first
>>>>>> >>> question would be is it possible to print legends with WFS?
>>>>>> >>>
>>>>>> >>> My second problem is related with layer order. When the app is
>>>>>> loaded,
>>>>>> >>> there
>>>>>> >>> are some initial layers that are loaded (WMS, WFS and  
>>>>>> TileCache). I
>>>>>> >>> also
>>>>>> >>> have the functionality to allow user to add additional layers
>>>>>> returned
>>>>>> >>> by
>>>>>> >>> WMS capabilities of geoserver. Because i wnated to keep all  
>>>>>> layers
>>>>>> that
>>>>>> >>> were
>>>>>> >>> initially loaded above all others i'm setting layers ZIndex
>>>>>> dynamically
>>>>>> >>> in
>>>>>> >>> the app. All is working fine when viewing and adding new layers  
>>>>>> (i
>>>>>> >>> always
>>>>>> >>> get inital loaded layers on top of the added ones). However,  
>>>>>> when
>>>>>> >>> trying
>>>>>> >>> to
>>>>>> >>> print, the added layers from wms capabilities are always on the  
>>>>>> top
>>>>>> of
>>>>>> >>> all
>>>>>> >>> others. More interesting is that, after printing, all layers are
>>>>>> >>> magically
>>>>>> >>> rearranged and in fact, the added layers become on top of all  
>>>>>> the
>>>>>> >>> others.
>>>>>> >>> What property am i missing here???
>>>>>> >>>
>>>>>> >>> Kind regards,
>>>>>> >>> Hugo
>>>>>> >>>
>>>>>> >>>
>>>>>> >>>  ______________________________****_________________
>>>>>> >>> Users mailing
>>>>>> >>> listUsers@geoext.orghttp://
>>>>>> www.geoext.org/cgi-bin/****mailman/listinfo/users<http://www.geoext.org/cgi-bin/**mailman/listinfo/users>
>>>>>> <http://**www.geoext.org/cgi-bin/**mailman/listinfo/users<http://www.geoext.org/cgi-bin/mailman/listinfo/users>
>>>>>> >
>>>>>>
>>>>>> >>>
>>>>>> >>>
>>>>>> >>>
>>>>>> >>> --
>>>>>> >>> Dipl.-Ing.(FH) Christian Mayer
>>>>>> >>>   - Anwendungsentwickler -
>>>>>> >>>
>>>>>> >>>   terrestris GmbH & Co. KG
>>>>>> >>>   Irmintrudisstraße 17
>>>>>> >>>   53111 Bonn
>>>>>> >>>
>>>>>> >>>   Tel:    ++49 (0)228 / 96 28 99 -53
>>>>>> >>>   Fax:    ++49 (0)228 / 96 28 99 -57
>>>>>> >>>
>>>>>> >>>   Email:  ma...@terrestris.de
>>>>>> >>>   Web:    http://www.terrestris.de
>>>>>> >>>
>>>>>> >>>   Amtsgericht Bonn, HRA 6835
>>>>>> >>>   Komplementärin:  terrestris Verwaltungsgesellschaft mbH
>>>>>> >>>   vertreten durch: Hinrich Paulsen, Till Adams
>>>>>> >>>
>>>>>> >>>
>>>>>> >>>
>>>>>> >>> ______________________________****_________________
>>>>>> >>> Users mailing list
>>>>>> >>> Users@geoext.org
>>>>>> >>>  
>>>>>> http://www.geoext.org/cgi-bin/****mailman/listinfo/users<http://www.geoext.org/cgi-bin/**mailman/listinfo/users>
>>>>>> <http:**//www.geoext.org/cgi-bin/**mailman/listinfo/users<http://www.geoext.org/cgi-bin/mailman/listinfo/users>
>>>>>> >
>>>>>>
>>>>>> >>>
>>>>>> >>>
>>>>>> >>
>>>>>> >>
>>>>>> >> --
>>>>>> >> Hugo Martins
>>>>>> >> LabNT - ISEGI UNL
>>>>>> >> Campus de Campolide
>>>>>> >> 1070-312 Lisboa
>>>>>> >> N 38°43'56.84", W 9°9'35.74"
>>>>>> >>
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>>
>>>>>>
>>>>>> --
>>>>>> --
>>>>>> Geoffrey BRUN
>>>>>>
>>>>>> Étudiant en master SIGMA
>>>>>> Stagiaire au PNR du Haut-Languedoc
>>>>>>
>>>>>> Hameau de Brassac
>>>>>> Saint-Pons de Thomières
>>>>>> +33 (0) 6 77 74 44 16
>>>>>> ______________________________****_________________
>>>>>> Users mailing list
>>>>>> Users@geoext.org
>>>>>> http://www.geoext.org/cgi-bin/****mailman/listinfo/users<http://www.geoext.org/cgi-bin/**mailman/listinfo/users>
>>>>>> <http:**//www.geoext.org/cgi-bin/**mailman/listinfo/users<http://www.geoext.org/cgi-bin/mailman/listinfo/users>
>>>>>> >
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>> --
>>>> --
>>>> Geoffrey BRUN
>>>>
>>>> Étudiant en master SIGMA
>>>> Stagiaire au PNR du Haut-Languedoc
>>>>
>>>> Hameau de Brassac
>>>> Saint-Pons de Thomières
>>>> +33 (0) 6 77 74 44 16
>>>>
>>>>
>>>
>>>
>>>
>>
>> --
>> --
>> Geoffrey BRUN
>>
>> Étudiant en master SIGMA
>> Stagiaire au PNR du Haut-Languedoc
>>
>> Hameau de Brassac
>> Saint-Pons de Thomières
>> +33 (0) 6 77 74 44 16
>>
>
>
>


-- 
-- 
Geoffrey BRUN

Étudiant en master SIGMA
Stagiaire au PNR du Haut-Languedoc

Hameau de Brassac
Saint-Pons de Thomières
+33 (0) 6 77 74 44 16
_______________________________________________
Users mailing list
Users@geoext.org
http://www.geoext.org/cgi-bin/mailman/listinfo/users

Reply via email to