arcgislink/examples/simpleags.js
function updateTOC() {
  if (ov && svc.hasLoaded()) {
    var toc = '';
    var scale = 591657527.591555 / (Math.pow(2, map.getZoom()));//591657527.591555 is the scale at level 0
    var layers = svc.layers;
    for (var i = 0; i < layers.length; i++) {
      var layer = layers[i];
      var inScale = layer.isInScale(scale);
      toc += '<div style="color:' + (inScale ? 'black' : 'gray') + '">';
      if (layer.subLayerIds) {
        toc += layer.name + '(group)<br/>';
      } else {
        if (layer.parentLayer) {
          toc += '&nbsp;&nbsp;&nbsp;&nbsp;';
        }
        toc += '<input type="checkbox" id="layer' + layer.id + '"';
        if (layer.visible) {
          toc += ' checked="checked"';
        }
        if (!inScale || svc.singleFusedMapCache) {
          toc += ' disabled="disabled"';
        }
        toc += ' onclick="setLayerVisibility()">' + layer.name + '<br/>';
      }
      toc += '</div>';
    }
    document.getElementById('toc').innerHTML = toc;
  }
  
}
function updateTOC() {
  if (ov && svc.hasLoaded()) {
    var toc = '';
    var scale = 591657527.591555 / (Math.pow(2, map.getZoom()));//591657527.591555 is the scale at level 0
    var layers = svc.layers;
    for (var i = 0; i < layers.length; i++) {
      var layer = layers[i];
      var inScale = layer.isInScale(scale);
      toc += '<div style="color:' + (inScale ? 'black' : 'gray') + '">';
      if (layer.subLayerIds) {
        toc += layer.name + '(group)<br/>';
      } else {
        if (layer.parentLayer) {
          toc += '&nbsp;&nbsp;&nbsp;&nbsp;';
        }
        toc += '<input type="checkbox" id="layer' + layer.id + '"';
        if (layer.visible) {
          toc += ' checked="checked"';
        }
        if (!inScale || svc.singleFusedMapCache) {
          toc += ' disabled="disabled"';
        }
        toc += ' onclick="setLayerVisibility()">' + layer.name + '<br/>';
      }
      toc += '</div>';
    }
    document.getElementById('toc').innerHTML = toc;
  }
  
}
function updateTOC ( ) { if ( ov && svc . hasLoaded ( ) ) { var toc = '' ; var scale = 591657527.591555 / ( Math . pow ( 2 , map . getZoom ( ) ) ) ; //591657527.591555 is the scale at level 0
 var layers = svc . layers ; for ( var i = 0 ; i < layers . length ; i ++ ) { var layer = layers [ i ] ; var inScale = layer . isInScale ( scale ) ; toc += '<div style="color:' + ( inScale ? 'black' : 'gray' ) + '">' ; if ( layer . subLayerIds ) { toc += layer . name + '(group)<br/>' ; } else { if ( layer . parentLayer ) { toc += '&nbsp;&nbsp;&nbsp;&nbsp;' ; } toc += '<input type="checkbox" id="layer' + layer . id + '"' ; if ( layer . visible ) { toc += ' checked="checked"' ; } if ( ! inScale || svc . singleFusedMapCache ) { toc += ' disabled="disabled"' ; } toc += ' onclick="setLayerVisibility()">' + layer . name + '<br/>' ; } toc += '</div>' ; } document . getElementById ( 'toc' ) . innerHTML = toc ; } }
Create layer list.
Create layer list .