Disable titles in Legend widget for specific layers within ArcGISDyMapService Layer

5351
12
Jump to solution
05-05-2015 08:10 AM
ArjunDongre
Occasional Contributor

It is possible to disable a title for a specific layer within a service when loaded into the Legend Widget?

1 Solution

Accepted Solutions
KellyHutchins
Esri Frequent Contributor

Yes. But an easy way to verify this is to use the browser debug tools.  For example in Chrome you can right-click on the legend label you want to hide and select the Inspect Element option from the menu to display the element and associated css.  Here's a screen shot that shows the elements tab after I select Inspect Element. If you look at the highlighted class that's the label I want to hide. Look up a few nodes and you'll see a div with a class of esriLegendService. The id for that div is the one you'll want to use.

Screen Shot 2015-05-05 at 10.12.07 AM.png

View solution in original post

12 Replies
RickeyFight
MVP Regular Contributor

Arjun,

Are you talking about the Legend Widget for Web AppBuilder ? If you are not can you post an example of what legend widget you are talking about?

0 Kudos
ArjunDongre
Occasional Contributor

No, I do not use the WebApp Builder. I am calling the Legend class from the API and adding specific layers within a service to the legend. Legend | API Reference | ArcGIS API for JavaScript . But, like in a normal legend in ArcMap where you can disable layer Titles/headings/lables, I was wondering if there was a way to disable the title.

0 Kudos
RickeyFight
MVP Regular Contributor

Arjun,

Try either of these CSS:

This one disables the bold "cemetery" below

.esriLegendServiceLabel {


  font-weight: bold;
  visibility: hidden;
}

OR

This one disables the "Cemetery Plots" below


.esriLegendLayerLabel {
  padding-top: 5px;
  visibility: hidden;
}

If you are trying to disable one title and not another that will be more work.

ArjunDongre
Occasional Contributor

Yes, I am trying to disable on and not the other. I had seen the CSS before. The only thing I can do is to ungroup the layers and post them as their own service, which is going to be make too many services to deal with, not to mention too many threads started on the server than is necessary. I guess I could build a legend widget from scratch...

0 Kudos
ArjunDongre
Occasional Contributor

I did run across that thread. It won't help me. Thanks for your help so far!

0 Kudos
KellyHutchins
Esri Frequent Contributor

If you know the id of the layer you want to disable the legend label for you could add a css rule specific to that layer.  So if my layer id was Naperville_Restaurants_505 I'd do something like this:

    #legendDiv_Naperville_Restaurants_505 .esriLegendServiceLabel{
      display: none;
    }
ArjunDongre
Occasional Contributor

So to be clear on syntax: I have 5 layers within my dynamic map service. One is called "Address Points". The div id for the legend is just "legend". So the call would be #legend_Address_Points.esriLegendServiceLabel?

0 Kudos
KellyHutchins
Esri Frequent Contributor

Yes. But an easy way to verify this is to use the browser debug tools.  For example in Chrome you can right-click on the legend label you want to hide and select the Inspect Element option from the menu to display the element and associated css.  Here's a screen shot that shows the elements tab after I select Inspect Element. If you look at the highlighted class that's the label I want to hide. Look up a few nodes and you'll see a div with a class of esriLegendService. The id for that div is the one you'll want to use.

Screen Shot 2015-05-05 at 10.12.07 AM.png