It is possible to disable a title for a specific layer within a service when loaded into the Legend Widget?
Solved! Go to Solution.
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.
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?
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.
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.
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...
I did run across that thread. It won't help me. Thanks for your help so far!
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; }
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?
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.