YLiAustin

Legend not displayed

Discussion created by YLiAustin on Sep 6, 2011
Latest reply on Sep 7, 2011 by YLiAustin
Hi,

My legend never displayed.  The alert message I put inside onLayersAddResult never fired up.  I do not know what is wrong.  I attached code here.  Please help and thanks.

function init()
            {
                var initExtent = new esri.geometry.Extent({
                    "xmin": 2940165,
                    "ymin": 9946407,
                    "xmax": 3233783,
                    "ymax": 10199898,
                    "spatialReference": {
                        "wkid": 2277
                    }
                });
                map = new esri.Map("map", {
                    extent: initExtent
                });
              // alert("AFTER map init")
               
                  //add the legend
                dojo.connect(map,'onLayersAddResult',function(results)
                {
                  alert("in the layer addresults");
                  var layerInfo = dojo.map(results, function(layer,index)
                  {
                    return {layer:layer.layer,title:layer.layer.name};
                  });
                  if(layerInfo.length > 0)
                  {
                    alert("layerinfo "+layerinfo);
                    var legendDijit = new esri.dijit.Legend({
                      map:map,layerInfos:layerInfo},"SideInfo");
                    legendDijit.startup();
                  }else
                  {
                   
                    alert("layerinfo is 0");
                  }
                });
       
                var tiledMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://wpdrgisdev1.coacd.org/ArcGIS/rest/services/FindYourWatershed/MapServer");
                map.addLayer(tiledMapServiceLayer);
               
                alert("after layer is added ");
       
                dojo.connect(map, 'onLoad', function(map){
                    dojo.connect(dijit.byId('map'), 'resize', resizeMap);
                });
               
               
                locator = new esri.tasks.Locator("http://wpdrgisdev1.coacd.org/ArcGIS/rest/services/COAGeocode/GeocodeServer");
                dojo.connect(locator, "onAddressToLocationsComplete", showAddressResults);
               
                map.infoWindow.resize(200, 125);
                dojo.byId("address").value="505 barton springs rd";
                //esri.hide("map");
               
             
            }

Outcomes