//bring in required classes
dojo.require("esri.dijit.Legend");
dojo.require("esri.dijit.Scalebar");
Scalebar
//in the init function after you have created the map
var scalebar = new esri.dijit.Scalebar({
map: map,
attachTo: "bottom-left"
});
Legend
//div for legend - added style positioning if you want it
<div id="legendDiv" style="position:absolute; bottom:10px; left:10px; z-index:40"></div>
//array to store legend layers
var legendLayers = [];
//after you define your dynamic map service layers push them into the array
legendLayers.push({layer:aerials,title:'Aerial Layer'});
legendLayers.push({layer:mcdonough,title:'McDonough Layer'});
//add the legend
dojo.connect(map, 'onLayersAddResult',function(results){
legend = new esri.dijit.Legend({
map:map,
layerInfos:legendLayers
},"legendDiv");
legend.startup();
});
Hope this helps,
Casey Schneebeck
The Nature Conservancy