jsn

Message  "No Legend"

Discussion created by jsn on Dec 14, 2012
Latest reply on Dec 21, 2012 by jsn
Hi all

I just started downloading this sample  "Map container split left"  that has a tab with a Legend

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm


and replaced the dynamicUrl map service with my service:

  var dynamicUrl = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/PublicSafety/PublicSafetyHazardsandRisks/MapServer";
        var referenceUrl = "http://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer";
        dynamicUrl = "http://<myserver>/ArcGIS/rest/services/OneLayer/MapServer";
 

When I run it I get instead of the Legend the following error message: "No Legend"

The map has a legend I just checked running it in my browser   http://<myserver>/ArcGIS/rest/services/OneLayer/MapServer/legend


This is the code I am running from the sample:

          dynamicUrl = "http://<myserver>/ArcGIS/rest/services/WASDDefault/MapServer";

        var basemap = new esri.layers.ArcGISTiledMapServiceLayer(basemapUrl);
        var dynamicLayer = new esri.layers.ArcGISDynamicMapServiceLayer(dynamicUrl,{opacity:0.45});
        var referenceLayer = new esri.layers.ArcGISTiledMapServiceLayer(referenceUrl);
      

        dojo.connect(map,'onLayersAddResult',function(results){
         //add the legend 
          var legend = new esri.dijit.Legend({
            map:map,
            layerInfos:[{layer:dynamicLayer,title:""}],
            arrangement:esri.dijit.Legend.ALIGN_RIGHT
          },"legendDiv");
          legend.startup();
        });
        
        map.addLayer(basemap);
        map.addLayers([dynamicLayer,referenceLayer]);
      }

Outcomes