[OpenLayers-Users] Layer selection in LayerSwitcher

Semantica jvanulde at nrcan.gc.ca
Thu Aug 28 16:13:15 EDT 2008


Hi Erik,

I unfortunately never got the chance to implement it in a production
environment but would be happy to package it up as a demo if someone would
post it to the OpenLayers demo page.  Let me know.

I have attached a screenshot of the custom layerSwitcher in action in case
you interested in what it looks like.  You will notice that the Capital
Cities layer is selected (has a border) and that the legend graphics are
coming from the provider WMS (National Atlas of Canada WMS). The legend
background had to be changed to white since legend graphics are sometimes
sent with a background, most often white.  You will also notice that the
Ocean Drainage Areas layer has a 50% opacity denoted by the opacity bar. 
Opacity is controlled by clicking the plus/minus buttons.

Cheers.


Erik Uzureau wrote:
> 
> Hello Semantica, can we see a version of this layer switcher live
> somewhere?
> erik
> 
> On Thu, Aug 28, 2008 at 2:50 PM, Semantica <jvanulde at nrcan.gc.ca> wrote:
>>
>> 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.
>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 
> 
http://n2.nabble.com/file/n790566/ol_custom_ls_SS.png ol_custom_ls_SS.png 
-- 
View this message in context: http://n2.nabble.com/Layer-selection-in-LayerSwitcher-tp789021p790566.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list