Legend Title / Layer Names

5693
7
Jump to solution
09-16-2012 03:19 PM
KeithGanzenmuller
Frequent Contributor
I need to suppress the Legend Title and the Layer Names.
Can't yet figure out how to show a legend without them.
Any help is appreciated.

Thanks,
Keith
0 Kudos
1 Solution

Accepted Solutions
KellyHutchins
Esri Frequent Contributor
You can use css to prevent the layer names from displaying. The API reference for the Legend Widget lists the available css classes.

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/legend.htm


Here's an example of css that I'd add if I wanted to  hide the display of the service title:


 .esriLegendServiceLabel {     display: none; }

View solution in original post

7 Replies
DavideLimosani
Frequent Contributor
try adding a title:" " in your legendInfos like this:


            var legend = new esri.dijit.Legend({
                map:map,
                layerInfos:[
   {layer:yourfirstlayer, title:" "},    
   {layer:yoursecondlayer, title:" "}         
                ]
            }, "legendDiv");
            legend.startup();
0 Kudos
CraigMcDade
Deactivated User
Hope this helps.

legendLayers.push({layer:layer,title:'YOUR TITLE'});
0 Kudos
KellyHutchins
Esri Frequent Contributor
You can use css to prevent the layer names from displaying. The API reference for the Legend Widget lists the available css classes.

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/legend.htm


Here's an example of css that I'd add if I wanted to  hide the display of the service title:


 .esriLegendServiceLabel {     display: none; }
Muhammad_SherazAhsan
Emerging Contributor

Thanks its helpful..

0 Kudos
KeithGanzenmuller
Frequent Contributor
Great, thanks everyone for your help.
0 Kudos
KeithGanzenmuller
Frequent Contributor
Hey Steve.
These questions and answers apply specifically to the Javascript API.

.esriLegendServiceLabel {
    display: none;
}

would go in the styles section and suppresses the output of the legend labels.

The other code would go in the script where you are creating your legend.
0 Kudos
KeithGanzenmuller
Frequent Contributor
Sorry about that, by the other code I meant the code snippets submitted by Davide and Craig in response to my question, included below.

    var legend = new esri.dijit.Legend({
                map:map,
                layerInfos:[
   {layer:yourfirstlayer, title:" "},   
   {layer:yoursecondlayer, title:" "}        
                ]
            }, "legendDiv");
            legend.startup();


  
legendLayers.push({layer:layer,title:'YOUR TITLE'});

These are two different ways to change the titles in the legend and would be included in the SCRIPT section of the code where you set up the legend.
0 Kudos