xupla

Displaying feature layer symbol in a custom table of contents

Discussion created by xupla on Jun 2, 2014
Latest reply on Jul 10, 2014 by sarahclark
I have built a custom table of contents similar  to the TOC widget http://www.arcgis.com/home/item.html?id=9b6280a6bfb0430f8d1ebc969276b109. The only problem I have is how I am going to display the feature layer icon as the legend.

function generateLegend(listOfLayers){ 
 require(["esri/layers/FeatureLayer", "dojo/on"],
 function (FeatureLayer, on) {
      
  //initialazing the feature layer and adding them in a list and on the map
  var layerList = [];
  for(var i=0; i < listOfLayers.length; i++){
   layerList[i] = new FeatureLayer(urlList[i]);
   map.addLayer(layerList[i]);
  }  

  for(var i = 0; i < nameList.length; i++){
   var layerId =  "Layer" + i; //id for the layer
   var layerPostid = "teste" + i; //id for the layer   
   
                        //I also want to display the icon here
   //html list to be dispalyed on the browser
   layerDisplay += "<li id='" + layerPostid + "'><input type='checkbox' checked='yes' id=" + layerId + ">" + legendIcon + "<a href='#' id=" + layerId + " onclick='return false;'>" + nameList[i] + "</a><ul><li><div class='slider'></div></li></ul></li>";    
  } 
 
  layerDisplay += "</ul>";   
  //displaying the legend 
  $("#tocLegend").html(layerDisplay);           
     
 });
}


Any ideas how I could achieve this please?

Outcomes