[OpenLayers-Users] How to obtain reference to map layer in 2.5????

plen peteralen at earthlink.net
Mon Apr 7 21:28:39 EDT 2008


Hello,

I am using OpenLayers 2.5.  Our situation is that we are getting a handle to
the map after someone else has loaded some WMS map layers.  So, by the time
I can do anything with the OpenLayers map, another group has added 10 or 11
map layers through calls like:

var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS", 
                "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'},
                options); 

I want to get a handle to a particular layer and I think I have to use the
OpenLayers API to get the layer.  For example, the 2.5 API has a
map.getLayer([layer_id]); and then a map.setBaseLayer(OpenLayers.Layer);
 
My question is that you have to have the layer ID as the argument for the
getLayer() function.  Since I did not load any of those layers, I don't know
how I would get the ID for the layer I am interested in.  There is no
generic function which returns an array of all the layers to which I could
just cycle through and check each layers name, for example.  Version 2.6 has
more functions to obtain layer data but we must use 2.5 for the time being.  

Any thoughts how I can programmatically go through the layers?

Thanks - Peter

-- 
View this message in context: http://www.nabble.com/How-to-obtain-reference-to-map-layer-in-2.5-----tp16545652p16545652.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list