Eliminate title row in TOC for one layer service

965
0
01-25-2017 04:20 PM
NhuMai
by
New Contributor II

This question is specifically for using map services containing one layer in NLiu's TOC. In the following code (from the widget), I am understanding that there is the possibility of eliminating the first row corresponding to the layer entry's title :

_createRootLayerNode: function(rootLayer){
 domClass.add(this.rowNode, 'agsjsTOCRootLayer');
 domClass.add(this.labelNode, 'agsjsTOCRootLayerLabel');
 var title = this.rootLayerTOC.config.title;
 // if it is '' then it means we do not title to be shown, i.e. not indent.
 if (title === '') {
 // we do not want to show the first level, typically in the case of a single map service
 esri.hide(this.rowNode);
 rootLayer.show();
 this.rootLayerTOC._currentIndent--;
 } else if (title === undefined){
 // no title is set, try to find default
 if (rootLayer.name){
 // this is a featureLayer
 title = rootLayer.name;
 } else {
 var start = rootLayer.url.toLowerCase().indexOf('/rest/services/');
 var end = rootLayer.url.toLowerCase().indexOf('/mapserver', start);
 title = rootLayer.url.substring(start + 15, end);
 }
 }
...
 }

However, when setting the title: as '', the service just doesn't appear in the TOC.  Anyone gotten this work? Am I misunderstanding what this part of the code is supposed to do?

function initLegend () {
 toc = new TOC({
 map: window.myMap,
 layerInfos: [
 {
 layer: OneLayerService,
 title: '',
 collapsed: true
 //layerList: layerInfo
 }
 ]
 }, 'legendDiv');
Tags (3)
0 Kudos
0 Replies