Select to view content in your preferred language

AGS JavaScript Api Combined TOC/Legend Contol

4924
13
06-16-2011 06:27 AM
SimonFisher
Frequent Contributor
Has anyone seen or been working on a Combined TOC/Legend Contol for the AGS JavaScript Api? something similar to what is available in the Web Adf TOC?  I have seen lots of examples, discussion, etc. on a Legend control or TOC control seperately, but nothing combined where the TOC simply has the symbology within it.

thx
Simon
0 Kudos
13 Replies
ArthurRodriguez
Emerging Contributor
Hello,

I am fairly new to Javascript programing, and trying to incorporate @kmacleod's suggestion to use multiple instances of the TOC/Legend widget, in an accordion style presentation within my legend.  In my attempts to work through this, I am first trying to simply add each layer into the TOC widget (within the legend pane), while also incorporate the transparency slider.  Note that I am working from the ArcGIS Basic Viewer web application, which may be part of my issue.

My code (below) works great for the first three layers, which are all tile services.  However, starting at layer 4, all remaining layers are Feature Services, and I keep getting errors that these layers are not being found, or not loaded.  If I call all layers (simply using layerInfos: layerInfo), then everything does get added to the legend (but no slider bars, of course, and then I can't split up what layers go into what accordion pane).   Any suggestions for what I may be doing wrong would be greatly appreciated!!!

-Arty

var legendDijit = new agsjs.dijit.TOC({//NL: new esri.dijit.Legend({
        map: map,  
        layerInfos: [{
    layer: map.getLayer(map.layerIds[1]),
    slider: true
  }, {
    layer: map.getLayer(map.layerIds[2]),
    slider: true
  }, {
    layer: map.getLayer(map.layerIds[3]),
    slider: true
  }, {
    layer: map.getLayer(map.layerIds[4]),
    slider: true  
  }]
    }, dojo.create('div'));

    dojo.byId('legendPanel').appendChild(legendDijit.domNode);
0 Kudos
MattDriscoll
Esri Contributor
0 Kudos
ArthurRodriguez
Emerging Contributor
Thank you, Matt, I may use this to set up my accordion panes when I get to that point.

Currently, I think my main issue is figuring out how to call individual layers within my map, which was set up through ArcGIS online.  The first three layers in my map are all tiled services, and seem to have easy to understand ID numbers: 1, 2, and 3.  I also can get the basemap added to my legend by using the ID 0 (zero).  After that, everything I try is coming up as undefined.  Any idea why this may be?  Are feature services ID numbers set up differently than other services?

Please let me know if this should be posted in another forum, or anything.

Thanks again,
-Arty
0 Kudos
GaneshSolai_Sambandam
Regular Contributor
Thank you, Matt, I may use this to set up my accordion panes when I get to that point.

Currently, I think my main issue is figuring out how to call individual layers within my map, which was set up through ArcGIS online.  The first three layers in my map are all tiled services, and seem to have easy to understand ID numbers: 1, 2, and 3.  I also can get the basemap added to my legend by using the ID 0 (zero).  After that, everything I try is coming up as undefined.  Any idea why this may be?  Are feature services ID numbers set up differently than other services?

Please let me know if this should be posted in another forum, or anything.

Thanks again,
-Arty


HI,
Can anyone tell me, how to get the ArcGISDynamic MapService layer name from map.getLayer(map.LayerIds(1)) method.
0 Kudos