[OpenLayers-Users] How to obtain reference to map layer in
2.5????
Paul Spencer
pagameba at gmail.com
Mon Apr 7 21:39:19 EDT 2008
I would imagine that you can use something like:
for (var i=0; i<map.layers.length; i++) {
var layer = map.layers[i];
//do something with the layer?
}
Cheers
Paul
PS Firebug is a great extension for firefox that allows you to inspect
live javascript objects like the map object and find what you need.
On 7-Apr-08, at 9:28 PM, plen wrote:
>
> 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.
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
More information about the Users
mailing list