Ryan Williams wrote:
>
> 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
>
Dear Ryan,
I couldn't ask for a more clear, thorough, and correct explanation. I thank
you so much for this! It truly worked a charm! And thanks to Bart for
providing the hints :)
Happy Mapping,
elshae
--
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/Get-A-Layer-s-ID-tp5896290p5896946.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users