Most samples and examples I have seen so far only display the legend and check-boxes separately within different tabs. Is there a way to have them together instead of switching tabs all the time to go toggle layers on or off as image bellow ?
In this case you have two case you choose which layer should be enable at what extent and also check/ uncheck as per your need in mxd file is used to create this service.And from javascript you can use layer enable function for layer to enable on loading or disable it
You can set the visibility of the layer (setVisible) and sublayers (setVisibileLayers), which will determine which checkboxes will be turned on when the TOC is first loaded.
This widget is working great with API 3.17. I cannot figure out how to deactivate the checkbox on load, however. Any suggestions?
I'm using the TOC dijit just fine with the 3.10 version of the API. It's the same TOC that I downloaded several months ago.
So, I downloaded the folder and added to my project. Also, I have the css linked. it is not working for me still. Am I missing something?
<link href="agsjs/css/agsjs.css" rel="stylesheet" />
<script src="http://js.arcgis.com/3.10/"></script>
<script type="text/javascript">
var dojoConfig = {
paths: {
//if you want to host on your own server, download and put in folders then use path like:
agsjs: location.pathname.replace(/\/[^/]+$/, '') + '../agsjs'
}
};
</script>
and here is the script:
// begin add the legend
map.on('layers-add-result', function(evt){
// overwrite the default visibility of service.
// TOC will honor the overwritten value.
// dynaLayer1.setVisibleLayers([2, 5, 8, 11]);
try{
toc = new agsjs.dijit.TOC({
map: map,
layerInfos: [{
layer: utilitiesLayer,
title: "Utilities"
}, {
layer: roads,
title: "Roads"
//collapsed: false, // whether this root layer should be collapsed initially, default false.
//slider: false // whether to display a transparency slider.
}]
}, 'legendDiv');
toc.startup();
catch(ex){
alert(ex.toString());
})
Hi Richard,
Did you leave off the actual link?
I agree, it's a great tool and I use it on several applications.
Thank you Tim,
This link is implementing the TOC dijit using "agsjs/dijit/TOC". I am having an error with it in 3.10. The page is not showing me the error but I now that name space is the problem.
I have to say, this is a great widget. I hope I'll make it work
Richard,
this should do it: http://www.arcgis.com/home/item.html?id=9b6280a6bfb0430f8d1ebc969276b109
Tim
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.