I don't think this is exactly the same as what you want to do, but maybe
it'll get you closer...
I use a function that gets the layer associated with a node when the
node in the tree is clicked.
It sounds like you already have the node, and you can get the layer
object with map.getLayersByName()...
I use
var lyrArray = map.getLayersByName(node.text);
When I use it I only expect to get one result so I just get the first
item in the array. I then get the opacity of that layer with
lyrArray[0].opacity
I think Bart is saying that if you want to set and get your own
variable, like 'layerId', you need to set it in the options section.
I set opacity in the options section when I create the WMS object, and I
think this is where you'd set your layerId value. If you do that, I
think you should be able to use lyrArray[0].layerId to get the id value.
here's an example:
var ISNT = new OpenLayers.Layer.WMS(
"ISNT Results", gwc_path,
{
layers: 'pub:ISNT'
},
{
opacity: 0.8,
layerId: 'somelayer'
}
);
- Ryan
On 1/6/2011 11:32 AM, elshae wrote:
Bart van den Eijnden (OSGIS)-2 wrote:
You're specifying it as a param not an option, so use the 4th argument of
the Layer.WMS constructor instead. To avoid name clashes use something
like layerId instead.
Bart, thanks for your reply. But my issue does not seem to be in setting
the id as I can see it set in FireFox, but rather obtaining it. I don't
know how to get the id after I have set it..
Thanks,
elshae
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users