HiJust 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
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; }
thanks for the reply, will have a crack at it next week.I see from the code that it will retrieve the sublayers....still a bit unsure how to get the check boxes in the first TOC and not in the second one, will do some investigation.thanks again.
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.