Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using GeoExt for my web mapping project. My web map includes a legend generated by GeoExt. Is it possible to turn off the layer title for a specific layer in legend? I am aware that there is a showTitle property for GeoExt.WMSLegend. However setting this property to false will turn off the layer titles of all the layers in the legend. Is there any way to turn off the layer title of just one single layer?

// Add a legend panel
legendPanel = new GeoExt.LegendPanel({
    map: map,
    title: 'Legend Panel',
    border: false,
    autoScroll: true,
    defaults: {
        showTitle: false,
        style: 'padding:5px',           
        baseParams: {
            FORMAT: 'image/png',
            LEGEND_OPTIONS: 'forceLabels:on;fontName=Verdana;fontSize:11'
share|improve this question
up vote 1 down vote accepted

The answer lies in the LayerLegend.js file (not obvious): when a new element is made in the legend, the title is determined by different tests:

  • if 'legendTitle' has been set in the defaults, this title will be used
  • the attribute 'hideTitle' (boolean) of the layer record (not the OpenLayers.Layer object, but the object) is checked, if it is true, then no title will be displayed
  • the attributes 'title' then 'name' are then checked
  • if none of theses attributes are found, then the OpenLayers.Layer object's name will be used.

So, you have to set the attributes 'hideTitle' to conditionally mask the layer's title in the legend. You can also customize the title of the layer, in case you'd like to use the layer's title as title of a group of layers. In that case, 'showTitle' in the LegendPanel has to be set to true.

share|improve this answer

Your Answer


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.