Dynamic TOC

865
2
07-30-2012 01:34 PM
KennyHoran
New Contributor III
I have an application with a huge layer tree structure.  A user starts by selecting a location and then the relevant layers are added to the map and the user can browse the TOC to toggle them.

I would like the user to view the TOC from the Layer List widget or the Map Switcher widget, however neither will initialize when configData.opLayers is empty.  As a result the uninitialized TOC will never show my new layers.  So, how can I initialize the TOC in the Map Switcher and Layer List plugins?

Note: Adding an operationallayer in config.xml will initialize both, but that's not ideal.
Tags (2)
0 Kudos
2 Replies
RhettZufelt
MVP Frequent Contributor
As you said, you could add an operational layer with alpha="0.0" and exclude from the TOC.

This would initialize, but would never be visible to the user.

I'm sure there is a more "proper" way to do this, but, this is ESRI afterall, so thought I'd chime in with a potential "work around" 😮

R_
0 Kudos
KennyHoran
New Contributor III
Aw, play nice!  That did work well though, I hadn't considered excluding my only layer.  That causes the TOCs to initialize and display a blank menu.  I just wish I had a bit more control and with that in mind I have two suggestions for ESRI.

1. Always initialize the TOC and have a configurable default message for when it's blank. -or-
2. Allow the TOC to be initialized on request.
0 Kudos