Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I specified the raster file with "name" and "title" in Geoserver.

For example, I have these in Geoserver:

name,  Title  
AT:usa, "This is a map of USA"  

Can I return the title ("This is a map of USA" ) as the layer name in Openlayers layer switcher when I call the WMS service for this layer by name? By default, it shows "usa" in the layer switcher.

share|improve this question
    
What is the value of the first param passed to the openlayers layer constructor? I bet it is "usa". Now do you want do dynamically fetch the layer name from geoserver? –  unicoletti Oct 1 '11 at 7:06
    
Do you think this is the only way? –  Seen Oct 1 '11 at 12:52
    
There are 2 ways: dynamic (difficult) and static (easy) –  unicoletti Oct 1 '11 at 13:18
    
I was expecting the title parameter would come with the post back WMS. So could you tell me how to do static one? Thanks! @unicoletti –  Seen Oct 1 '11 at 14:58
add comment

1 Answer

up vote 1 down vote accepted

I suppose you are creating your OpenLayers WMS layer as follows:

var wms = new OpenLayers.Layer.WMS("This is a map if USA",
                               "http://yourgeoserver/geoserver/wms",
                               {layers: "AT:usa"});

then the first parameter is the layer name that will be displayed in the layer switcher. Simply set it to whatever you like it to be.

share|improve this answer
    
I think this is an easy way to get around. That is how I did it exactly. Thanks! –  Seen Oct 1 '11 at 16:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.