Hi
Just working on getting a nice legend for my service. I have followed the instructions and the legend works fine however i require checkboxes for each sublayer in the service instead of the higher layer. Does anyone know how i would be able to achieve this?
I would like to do it automatically so i dont need to manually change anything when using the code in another application for example. I just would like it to loop through, see sublayers and add the option for a checkbox to turn it on/off, unsure why this is not included as it seems so common for end users to do???
thanks
Try something like this:
function getSubLayers(layer) {
var infos = layer.layerInfos, info, i, il, subLayerArray;
for (i=0, il = infos.length; i<il; i++) {
info = infos;
if (!info.subLayerIds) { // if the layer doesn't have a subLayer, ...
subLayerArray.push(info.id); // ...function adds the layer's id to an array
}
}
return subLayerArray;
}