[GIS] How to get WMS layer title instead of layer name from Geoserver

geoserveropenlayers-2wms

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.

Best Answer

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.