deleted-user-ugCMpXci8bn5

legend only displays basemap layers

Discussion created by deleted-user-ugCMpXci8bn5 on Aug 13, 2012
Latest reply on Apr 17, 2013 by deleted-user-ugCMpXci8bn5
Hello,

I am having trouble getting a Legend to work properly. I have read through the forums and seen similar issues but none that were quite the same as mine... I am using this code below (taken from the API examples).  When I run this as is, the content pane displays only 'No Legend'..but when i comment out the 'layerInfos' line, I get a legend for the basemap only.  I would like a legend for the dynamic layer and not the basemap.
The other commented out lines are from other attempts to make this work.

I am using a single TiledMapServiceLayer for a basemap and a single DynamicMapServiceLayer. I am testing this using Visual Studio in an MVC 3 framework.

Thanks, Jason


        dojo.connect(map, "onLayersAddResult", function (results) {

          var layerInfo = dojo.map(results, function(layer,index){

              return { layer: layer.layer, title: layer.layer.name };
         
          });

            if (layerInfo.length > 0) {
                var legendDijit = new esri.dijit.Legend({
                    map: map,
                    //title: 'Legend',
                     layerInfos: layerInfo,
                   // layerInfos: ({layer:ssLayer}),
                  //  layer: ssLayer,
                  // respectCurrentMapScale: false

                }, "legendDiv");
                legendDijit.startup();
            }
        });
        map.addLayers([ssLayer]);

Outcomes