[fusion-users] Get layer name from Legend right-click

Mike Adair madair at dmsolutions.ca
Thu Apr 15 11:25:34 EDT 2010


Tom,

Then your getRasterQuery method would look like:

function getRasterQuery(layer) {
    var temp = layer.name;
...
}

For the OpenLayers.Function.bind method, the first arg is the method to 
be bound, the second arg is the object to bind to (object will be 'this' 
inside the method), and then the rest of the arguments will be passed to 
the bound method as arguments.

Mike


Tom van der Putte wrote:
> Hi Mike,
>
> I was trying your solution, but I'm still a bit confused.
>
> This is my current code (within Legend.LegendRenderer)
>
> this.executeRasterQueryAction = new 
> Jx.Action(OpenLayers.Function.bind(this.getRasterQuery, this));
> this.executeRasterQueryItem = new 
> Jx.MenuItem(this.executeRasterQueryAction, {label: 
> OpenLayers.i18n('Execute raster query')});
>
> According to your explanation, the first line should then be:
>
> this.executeRasterQueryAction = new 
> Jx.Action(OpenLayers.Function.bind(this.getRasterQuery, this, layer));
>
> Or am I wrong here? But how do I get the reference to the layer thats 
> clicked? Does that make sense what I'm saying? :) I'm not really into 
> the whole binding stuuf yet. Getting there though...
>
> Cheers,
> Tom
>
>
>
> On Thu 15/04/10 15:52 , Mike Adair madair at dmsolutions.ca sent:
>
>     Tom,
>
>     The menu items are only bound to the legend tree items/folders at
>     this
>     point. I think what you would need to do is bind whatever object you
>     need when setting up your onclick event, eg. the existing code
>     looks like:
>     onClick:
>     OpenLayers.Function.bind(this.collapseBranch, this, this.oRoot)
>
>     but you probably want:
>
>     onClick:
>     OpenLayers.Function.bind(this.collapseBranch, this, this.oRoot, layer)
>
>     (or similar) and then in the method being bound, layer will appear as
>     one of the arguments.
>
>
>     Mike
>
>
>     Tom van der Putte wrote:
>     > Hi All,
>     >
>     > When right-clicking an item in the legend, a context manu appears.
>     > I've added a entry to this menu, and clicking on it results in a
>     > certain function beeing executed. However, I want to check if the
>     item
>     > that was right-clicked in the legend is of a certain type. How can I
>     > get to the layer name? I found something like targetFolder in the
>     > legend widget, but this obviously goes only for the folders?
>     >
>     > Cheers,
>     >
>     > Tom
>     > ------------------------------------------------------------------------
>     >
>     > _______________________________________________
>     > fusion-users mailing list
>     > fusion-users at lists.osgeo.org
>     <javascript:top.opencompose('fusion-users at lists.osgeo.org','','','')>
>     > http://lists.osgeo.org/mailman/listinfo/fusion-users
>     <parse.php?redirect=http%3A%2F%2Flists.osgeo.org%2Fmailman%2Flistinfo%2Ffusion-users>
>     >
>
>     -- 
>     Michael Adair
>     Senior Software Architect
>     DM Solutions Group Inc.
>
>     Office: (613) 565-5056 x26
>     madair at dmsolutions.ca
>     <javascript:top.opencompose('madair at dmsolutions.ca','','','')>
>     http://www.dmsolutions.ca
>     <parse.php?redirect=http%3A%2F%2Fwww.dmsolutions.ca>
>     http://research.dmsolutions.ca
>     <parse.php?redirect=http%3A%2F%2Fresearch.dmsolutions.ca>
>
>
>

-- 
   Michael Adair
   Senior Software Architect
   DM Solutions Group Inc.

   Office: (613) 565-5056 x26
   madair at dmsolutions.ca
   http://www.dmsolutions.ca
   http://research.dmsolutions.ca




More information about the fusion-users mailing list