Select to view content in your preferred language

ToC for Viewer: Collapse all legends

2186
10
07-18-2012 02:55 PM
JustinGleeson
Deactivated User
Hi All,

Am using the ToC widget for Flex 2.5 and am having trouble getting the legends to open as 'collapsed'. I'm using the following code within the ToC.xml file.[ATTACH=CONFIG]16224[/ATTACH]

<tocsettings>
<expanded>false</expanded>
<collapselegends>false</collapselegends>
</tocsettings>

Ideally I want all layers and legends collapsed/closed so the user has to click and expand to view.

any help appreciated

thanks

Justin
Tags (2)
0 Kudos
10 Replies
RhettZufelt
MVP Notable Contributor
Since you didn't post the entire xml, I'm assuming your <tocsettings> is within the <configuration> tags.

I just tested it and
 <tocsettings>
  <expanded>false</expanded>
 </tocsettings>


works fine for me.

You may want to make sure the changes are being pushed to your server.  I have had similar issues in the past that deleting the TOCWidget.swf from the server (and make sure the TOCWidget.xml on the server is showing your changes) and re-building the project has fixed.

R_
0 Kudos
JustinGleeson
Deactivated User
Thanks

Below is the full code from Robert's widget. Using this the layers need to be expanded by the users when opened and this is what I want. The problem is that all the legends are already expanded. What I would like to do is click 'Population Maps', this would list the maps/layers and then click again to see the legend. As it stands once I click 'Population Maps' it shows all the maps/layers in a list with the legends already expanded. This is a probelm as it means the user has to do a lot of scrolling to get to the bottom of the list.

thanks

Justin

[HTML]<configuration>
<labels>
  <visibilitylabel>Layer Visibility</visibilitylabel>
  <zoomtoextent>Zoom To Layer Extent</zoomtoextent>
  <expandall>Expand All Layers</expandall>
  <collapseall>Collapse All Layers</collapseall>
  <zoomtomakevisible>Zoom To Make Visible</zoomtomakevisible>
  <generatinglegendmsg>Generating TOC Legend</generatinglegendmsg>
</labels>
<tocsettings>
  <expanded>false</expanded>
  <collapselegends>false</collapselegends>
</tocsettings>
<legendtimeout>60</legendtimeout>
<excludelayers>
  <excludelayer mapservice="Symbols"></excludelayer>
  <excludelayer mapservice="Utilities">8</excludelayer>
</excludelayers>
<excludegraphiclayers>true</excludegraphiclayers>
<excludebasemaplayers>true</excludebasemaplayers>
<usenewesridescription>true</usenewesridescription>
</configuration>[/HTML]
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Justin,

   Well for that you just need to pay close attention to the TOCWidget.xml tag names.

<configuration>
    <labels>
        <visibilitylabel>Layer Visibility</visibilitylabel>
        <zoomtoextent>Zoom To Layer Extent</zoomtoextent>
        <expandall>Expand All Layers</expandall>
        <collapseall>Collapse All Layers</collapseall>
        <zoomtomakevisible>Zoom To Make Visible</zoomtomakevisible>
        <generatinglegendmsg>Generating TOC Legend</generatinglegendmsg>
    </labels>
    <tocsettings>
        <expanded everything="false">false</expanded>
        <collapselegends>true</collapselegends>
        <disablezoomtomenuoption>true</disablezoomtomenuoption>
    </tocsettings>
    <legendtimeout>60</legendtimeout>
    <excludelayers>
        <excludelayer mapservice="Symbols"></excludelayer>
        <excludelayer mapservice="Utilities">8</excludelayer>
    </excludelayers>
    <excludegraphiclayers>true</excludegraphiclayers>
    <excludebasemaplayers>true</excludebasemaplayers>
    <usenewesridescription>true</usenewesridescription>
</configuration>
0 Kudos
JustinGleeson
Deactivated User
Hi Robert,

Thanks for help again and developing this really useful widget. I've adjuted the TOC settings as per your reply but still not getting the solution.

When it open it's displays the way I want like image 1
[ATTACH=CONFIG]16237[/ATTACH]

But, when I click on a theme, say population, it has all of the legends open as per image 2. This is not what I want.
[ATTACH=CONFIG]16240[/ATTACH]

Ideally I'd like it to display it the same way as in your example here: http://gis.calhouncounty.org/FlexViewer3.0/index.html?config=config-toc.xml

<tocsettings>
        <expanded everything="false">false</expanded>
        <collapselegends>true</collapselegends>
        <disablezoomtomenuoption>true</disablezoomtomenuoption>
    </tocsettings>
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Justin,

   You need to make sure you are actually getting the xml change when you run the code, because what you are after is exactly what you should get when you set the xml as instructed. This has been tested and verified. Are you using the latest 2.5 version of this widget?
0 Kudos
JustinGleeson
Deactivated User
Yes, working with the 2.5 version that is linked on the Code Gallery Table of Contents version for 3.0
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Justin,

  My concern on if you are using the latest 2.5 version (2.5.1.1) is the fact that the xml you posted originally was missing a couple of the new tags and attributes so that lead me to believe that you were not using the latest version. I am not sure what to tell you as I have tested and verified that I can get your desired results (the same you see on the live preview site) with the xml that I provided you.
0 Kudos
JustinGleeson
Deactivated User
Robert,

I appreciate your help on this and I've included the exact code you provided me with but still can't understand why the legends remain expanded. I'm thinking now that it must be something to do with my main config file as the ToC is exactly the same as in the above reply. If you have some spare time you might have a look.

thanks

Justin

ToC.xml
[HTML]<configuration>
<labels>
  <visibilitylabel>Layer Visibility</visibilitylabel>
  <zoomtoextent>Zoom To Layer Extent</zoomtoextent>
  <expandall>Expand All Layers</expandall>
  <collapseall>Collapse All Layers</collapseall>
  <zoomtomakevisible>Zoom To Make Visible</zoomtomakevisible>
  <generatinglegendmsg>Generating TOC Legend</generatinglegendmsg>
</labels>
<tocsettings>
  <expanded everything="false">false</expanded>
  <collapselegends>true</collapselegends>
</tocsettings>
<legendtimeout>60</legendtimeout>
<excludelayers>
  <excludelayer mapservice="Symbols"></excludelayer>
  <excludelayer mapservice="Utilities">8</excludelayer>
</excludelayers>
<excludegraphiclayers>true</excludegraphiclayers>
<excludebasemaplayers>true</excludebasemaplayers>
<usenewesridescription>true</usenewesridescription>
</configuration>[/HTML]

Main Config

[HTML]<configuration>
    <title>AIRO: Vacant Ireland</title>
    <subtitle>Vacancy and Unfinished Estates</subtitle>
    <logo>Census11_WidgetsETC/assets/AIROTwitter.png</logo>
    <style>
        <colors>0xffffff,0x72a7d3,0xf6b54f,0xf6b54f,0xffffff</colors>
        <alpha>1.0</alpha>
    </style>
    <!-- replace the following url with your own geometryservice -->
    <geometryservice url="http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer" />

<splashpage label="ArcGIS Viewer for Flex" config="VacantIreland_WidgetsETC/widgets/Splash/SplashWidget_VacantIreland.xml" url="VacantIreland_WidgetsETC/widgets/Splash/SplashWidget.swf"/>

    <!-- User Interface elements -->
    <widget left="10"  top="50"    config="widgets/Navigation/NavigationWidget.xml" url="widgets/Navigation/NavigationWidget.swf"/>
   <widget right="-2" bottom="-2" config="widgets/OverviewMap/OverviewMapWidget.xml" url="widgets/OverviewMap/OverviewMapWidget.swf"/>
    <widget left="0"   top="0"     config="widgets/HeaderController/HeaderControllerWidget.xml" url="widgets/HeaderController/HeaderControllerWidget.swf"/>
 

   <map wraparound180="true" initialextent="-1276000 6690000 -530000 7485000" fullextent="-1276000 6690000 -530000 7485000" top="40">
        <basemaps>
      <layer label="OpenStreetMap" type="osm" visible="true" />
                  <layer label="Aerial" type="tiled" visible="false" url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer" />
        </basemaps>
  
        <operationallayers>
    
   <layer label="Boundaries" type="dynamic" visible="false" alpha="0.5"
                   url="http://airomaps.nuim.ie/ArcGIS/rest/services/Census2011PDR/Boundaries/MapServer"/>
 
  <layer label="Population" type="dynamic" visible="true" alpha="0.6"
         url="http://airomaps.nuim.ie/ArcGIS/rest/services/Census2011PDR/PopulationMaps/MapServer">
  <sublayer id="0" popupconfig="Census11_WidgetsETC/Popups/PopUp_PopDens_11ED.xml"/>
  <sublayer id="1" popupconfig="Census11_WidgetsETC/Popups/PopUp_PopCh_0611.xml"/>
       </layer>
       
      
  <!--<layer label="Population Maps" type="dynamic" visible="true" alpha="0.6"
                   url="http://airomaps.nuim.ie/ArcGIS/rest/services/Census2011PDR/PopulationMaps/MapServer"/> -->
      
        </operationallayers>
    </map>
    <!-- widgets organized into widget containers that manage close/open etc -->
    <!-- supported layout property options: horizontal(default)|float|vertical|fix-->

  
   <widgetcontainer layout="float">
 
      
        <widget label="Save a local bookmark" left="430" top="90"
                icon="assets/images/i_bookmark.png"
                config="widgets/Bookmark/BookmarkWidget.xml"
                url="widgets/Bookmark/BookmarkWidget.swf"/>
        <widget label="Print the Map" left="390" top="400"
                icon="assets/images/i_print.png"
                config="widgets/Print/PrintWidget.xml"
                url="widgets/Print/PrintWidget.swf"/>
    <widget label="Please Choose a Map from the themes below..."left="90" top="50" width="350" height="450"
      preload="open"
               icon="assets/images/i_folder.png"   
            config="widgets/TOC/TOCWidget.xml"
            url="widgets/TOC/TOCWidget.swf"/>

    </widgetcontainer>

</configuration>[/HTML]
0 Kudos
RhettZufelt
MVP Notable Contributor
You might try this change:

<visibilitylabel>Testing</visibilitylabel>
and then reload your project.

Of course, this won't fix it, but it will let you know for sure if the browser is picking up on the changes you make.

Espescially if using IE, I find that, depending on the workstation it is installed on, a <cntrl><F5> will reload with all changes, on other computers you MUST close the entire browser and then re-open the flex page.

Anyway, just a thought as I've had this issue before also.

R_
0 Kudos