Table of Contents - Legend Widget for FlexViewer 2.x

115549
664
12-01-2010 07:30 AM
RobertScheitlin__GISP
MVP Emeritus
All,

Here is the next in my line of widgets for the FlexViewer 2.x.

The legend portion of this widget is the same code as my dynamic legend widget so,

IT IS FOR ARCGIS SERVER 10 OR GREATER ONLY

This is just a simple TOC Widget that includes my dynamic legend component.
This widget also includes my enhancement for map service transparency,
right click context menu for zoom to make layer visible, and my scale
dependent renderer for the TOC checkboxes.
Tags (2)
0 Kudos
664 Replies
RobertScheitlin__GISP
MVP Emeritus
Michael,


  1. Using the compiled version you would have to change your FVs style tags to change that. Using the uncompiled you could make a coding change to handle that.

  2. One my site I am using the FV 3.0 and one of my 3.0 version of the TOC widget where the interaction with the TOC and MapSwither was fixed. But no you can not get this fix for the 2.5 compiled version.

0 Kudos
MicahWilliamson
Occasional Contributor II
Nope, not anymore. Bad coding on my part. :cool:

Hey Mike!

-
0 Kudos
ErikMartin
Occasional Contributor
Robert,

Is there a way to exclude FeartureLayers from the TOC widget?  I've messed around with the order in TOC.as, following your message above to Jim, but have not figured out how to exclude them altogether.

Thanks, as always!
-Erik
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Erik,

   Excluding layers is as simple as this:

<excludelayer url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Louisville/LOJIC_LandRecords_Louisville/MapServer" id="0"/>


An example straight from the IdentifyWidget.xml that come with the download.
0 Kudos
RhettZufelt
MVP Notable Contributor
Or an example from the TOC widget config:
  <excludelayer mapservice="Earthquakes"></excludelayer>
  <excludelayer mapservice="Fires"></excludelayer>


Or like this to ONLY exclude sublayer 0 and 1 if dynamic:

  <excludelayer mapservice="Earthquakes">0,1</excludelayer>

R_
0 Kudos
ErikMartin
Occasional Contributor
The contents of my TOCWidget.xml now read:

<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>10</legendtimeout>
 <excludelayers>
  <excludelayer url="http://maps.myserver.com/mapstest/rest/services/Project/Test/MapServer" id="1"/>
 </excludelayers>
 <excludegraphiclayers>true</excludegraphiclayers>
 <excludebasemaplayers>true</excludebasemaplayers>
 <usenewesridescription>false</usenewesridescription>
</configuration>


I also tried
<excludelayer mapservice="Layers">1</excludelayer>


With both configurations, Layer 1 from my map service is still showing p in the TOC.  More significantly, the FeatureLayer that is created from MapService Layer 1 in AS & added to the map (via a separate custom widget) is showing up in the TOC as "FeatureLayer774".  Then, when I remove that FeatureLayer from the map via AS, the TOC throws an error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
 at widgets.TOC.toc.tocClasses::TocMapLayerItem/filterOutSubLayer()
 at widgets.TOC.toc.tocClasses::TocMapLayerItem/processLegend()
 at Function/<anonymous>()
 at flash.events::EventDispatcher/dispatchEventFunction()
 at flash.events::EventDispatcher/dispatchEvent()
 at HTTPOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()
 at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()
 at mx.rpc::Responder/result()
 at mx.rpc::AsyncRequest/acknowledge()
 at DirectHTTPMessageResponder/completeHandler()
 at flash.events::EventDispatcher/dispatchEventFunction()
 at flash.events::EventDispatcher/dispatchEvent()
 at flash.net::URLLoader/onComplete()


Is there something obvious I'm missing?
0 Kudos
RhettZufelt
MVP Notable Contributor
This is what I found to keep a MapService loaded as type="feature" from displaying in the TOC widget:

<excludelayers>
     <excludelayer mapservice="Layers"></excludelayer>
</excludelayers>


Do not put put the sublayer id in there with a type="feature" or it will only remove "part" of it from the TOC (I.e., I still see it, just won't turn on/off and no symbology or plus sign).

I have randomly been getting null value errors as well, reload without change, and it works fine (does not work in Chrome) and the version 3.1.5 errors out for me a fraction of the time compared to 3.2.

Didn't have these issues until I tried to exclude a feature layer, so may be related to this somehow.

Do you have the LayerList widget active, or maybe the mapswitcher "More" button?  I notice that if I try to enable the layerlist, I get errors much more often.

Anyway, time to go for the weekend, no more testing until Monday.  However, I have tested the excludelayer coding above and works for me.

R_

Since you are adding the featurelayer other than the main config, have you tried this:

<excludelayer mapservice="FeatureLayer774"></excludelayer>


perhaps your code only adds a layer name and not an ID?  It is my understanding it needs an id to be programatically searched for.

fLayer.name = dLayer.id = item.name; worked for me in a previous widget to see layers added by another.
0 Kudos
KennyWebster
New Contributor III
Hi all,

I've noticed some odd behaviour related to the zoom to menu option.

We're using Flex Viewer 3.0 along with version 3.0 of the TOC widget.

What I've been able to identify is that when the disablezoomtomenuoption is set to false in the config things seem to work ok.  However we would like to set it to true.  The behaviour we've noticed is that the menu option is disabled entirely (the button doesn't exist to click) if the layers are visible (user is zoomed in).  When the user zooms out to where a layer is no longer visible, the menu option will reappear and allow the user to zoom to visible, I believe this is all by design.  Now this is where things get a little quirky.  We have a handful of layers (~5) which do not disable the menu button once they become visible.  However, the button cannot be clicked, it doesn't work.  For the rest, all works as described above.

My first thought is that it has something to do with the those specific layers.  But as of yet I have been unable to find a pattern they relates the offending layers and differs them from every other layer.

If anyone has any suggestions on what direction I should be going here to fix this I would be greatly appreciate it!
0 Kudos
JasonStanton__GISP
Occasional Contributor
Robert,

I posted this question a couple of weeks ago.  I'm guessing you just missed it so I wanted to follow-up.

Have you ever considered adding the ability to save legend properties similar to the eBookmark or eDraw widget? For example if the user has turned layers on/off or set transparencies they could save those 'settings' and load them back in later? I'm not even sure that's possible, but one of our communities asked for this.

If you could let me know either way I would greatly appreciate it.  Thanks!

Jason
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Jason,

   No I have really not considered that. It seems like a lot of work for a minimal return. It could be done in code as I believe that the setting of a layers visibility programmatically is now captured in the toc (i.e. checked or not, this was a issue before). I can not say I will be considering this as an enhancement though as I currently have no free time.
0 Kudos