I have a map template that I use to display a variety of feature layers and dynamic layers.
I have found a snippet of code to add the legend to my map:
//add the legend
dojo.connect(myMap, '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: myMap,
layerInfos: layerInfo},
"legendDiv");
legendDijit.startup();
}
});
The issue is, I can't figure out how to configure the names of the layers, labels, descriptions, etc. Most of the layers in my service are symbolized by Category, so, I want to be able to display those category names in the Legend.
This is what I want to show..or something like it, but with a category or layer heading
This is what shows up. No heading, just the categorized layer without a title or anything.
Any help would be appreciated.
Thanks