6 Replies Latest reply on Sep 18, 2012 12:59 AM by kganz

    Legend Title / Layer Names

    kganz
      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
        • Re: Legend Title / Layer Names
          dlimos
          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();
          
          • Re: Legend Title / Layer Names
            mcdade31
            Hope this helps.

            legendLayers.push({layer:layer,title:'YOUR TITLE'});
            • Re: Legend Title / Layer Names
              khutchins-esristaff
              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; }
              • Re: Legend Title / Layer Names
                kganz
                Great, thanks everyone for your help.
                • Re: Legend Title / Layer Names
                  kganz
                  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.
                  • Re: Legend Title / Layer Names
                    kganz
                    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.