[OpenLayers-Users] Layer selection in LayerSwitcher
Semantica
jvanulde at nrcan.gc.ca
Thu Aug 28 15:50:40 EDT 2008
Sorry, in my last post I forgot to indicate how to access the selected layer.
As you will see I added a property on the layerSwitcher called activeLayer.
This property stores the layer id (layer.params.LAYERS).
To make a layer active, the user clicks on the layer title in the
layerSwitcher. The title bar is highlighed with a border and the
activeLayer property is set the the layer id. So to access the layer
associated with that id (i.e. the active layer) you simply do this:
var layerId = layerSwitcher.activeLayer;
var activeLayer = map.getLayer(layerId);
Then you can access the layer properties for example if you wan't the
getFeatureInfo request string you would do the following:
var url = activeLayer.getFullRequestString({
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: activeLayer.map.getExtent().toBBOX(),
X: evt.xy.x,
Y: evt.xy.y,
INFO_FORMAT: 'text/html',
QUERY_LAYERS: activeLayer.params.LAYERS,
WIDTH: activeLayer.map.size.w,
HEIGHT: activeLayer.map.size.h});
Again, I hope this helps.
Cheers and good luck!
Bas Couwenberg wrote:
>
> Hello,
>
> is it possbile with the LayerSwitcher control to select a layer (I don't
> mean turn invisible) which I then could use to change it opacity. The
> opacity part works well from the examples but I want to do this per layer
> I
> select.
>
> Best regards,
>
> Bas Couwenberg
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>
--
View this message in context: http://n2.nabble.com/Layer-selection-in-LayerSwitcher-tp789021p790516.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list