Dynamic Legend widget for Flexviewer 2.0

5336
65
07-29-2010 01:18 PM
RobertScheitlin__GISP
MVP Emeritus
All,

    I am happy to announce the first community developed (and shared on the code gallery) widget for the Flexviewer 2.0. I have finalized my Dynamic Legend Widget for the 2.0 FlexViewer and shared it for all to use.

This version is COMPLETELY dependent on 2 things

  1. ArcGIS Server 10 map services

  2. Flex Viewer 2.0 and obviously Flex API 2.0


I have made it XML configurable this time so that you can specify that certain map services or certain layers in a map service are not to be displayed in the widget.

It is called dynamic because the legend will only draw map services and layer that are visible in your map. It respects scale dependency of layers and if the layer is checked in the TOC or operational layer TOC. The legend automatically redraws when layers have been checked/unchecked and when zooming in or out and a layer scale dependency has been meet.

I hope you enjoy it and I HOPE that you read and understand that it will not work with mapservices that are not served from a ArcGIS 10 Server.

http://www.arcgis.com/home/item.html?id=f60406b9f52340d59eb557bf64136af6

PS. don't forget to rate the code.
Tags (2)
0 Kudos
65 Replies
ShawnKraft
Occasional Contributor
Hey Robert.  This will work with the mapservice only and not the operational layers correct?  Reason I ask is because here is how I have mine set up currently. 

map initialextent="506359 283843 559527 309834 3736">
        <basemaps>
         <mapservice label="Aerial" type="image" visible="true" alpha="1"                 url="http://icarus/ArcGIS/rest/services/Aerial/ImageServer"/>                   
        </basemaps>
        <operationallayers>           
            <layer label="CityLayers" type="dynamic" visible="true"
                     url="http://icarus/ArcGIS/rest/services/PublicWorksFlex/MapServer"/>
        </operationallayers>
    </map>

So I am using the LayerListWidget to display all the layers in the operationallayers and allow users to turn them on/off.  My aerial is huge and it really is smoking fast generating on screen set up this way as opposed to having the image in the LayerListWidget.  Any suggestions on how I can implement the Dynamic Legend another way?
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Shawn,

   Operational Layers work just fine as long as they are coming from a ArcGIS 10 Server.
0 Kudos
ShawnKraft
Occasional Contributor
Yep its an ArcGIS 10 server.  Hmmm I know I have all the other parameters set the way you stated, i.e. flex compiler and build path.  The Dynamic Legend is functioning, it opens, just nothing shows inside the window.  Wonder what I haven't done.  So what I have posted above looks okay to you as far as it relates to the DynamicLayer Widget correct?
0 Kudos
ShawnKraft
Occasional Contributor
Although, I do have this in the additional compiler arguments

-locale en_US -source-path=locale/{locale} -keep-all-type-selectors=true

not sure if the -keep-all-type...... needs to be there or not.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Shawn,

    Yep it looks fine does CityLayers have a min or max scale set on it? Does it show on your maps and not in the legend? Do you have at least some of the sub-layers of the map service turned on?
0 Kudos
ShawnKraft
Occasional Contributor
CityLayers doesn't have any max/min scale set on it.  CityLayers shows on my map, and I can turn its layers on/off in the LayerList widget.  I have two layers in the map service turned on by default, my right of way layer and address point layer.  Not sure if I answered you correctly.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Shawn,

   So look at my service directory page for this layer
http://gis.calhouncounty.org/ArcGIS2/rest/services/ParcelViewer/MapServer/84

Notice the :

Drawing Info:

      Renderer:
            Simple Renderer:
            Symbol:
                  Simple Fill Symbol:
                  Style: esriSFSSolid, Color: [255, 250, 200, 255]
                  Outline:
                        Simple Line Symbol:
                        Style: esriSLSSolid, Color: [0, 0, 0, 255], Width: 0.4Label:
            Description:
      Transparency: 0
      Labeling Info: N/A

does your map service have that info?
0 Kudos
ShawnKraft
Occasional Contributor
Yeah um Robert, I do not have any of that.  Sheesh!  So I need to add rendering.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Shawn,

   That has me scratching my head than because the drawing info should automatically come from the MXD or MSD when you publish your map service in ArcGIS Server 10.
0 Kudos
ShawnKraft
Occasional Contributor
Great, so I am the oddball lol.  That could be the issue though Robert.  I didn't publish my mxd directly from inside ArcMap.  Instead, I go to my ArcGIS Server Manager app and add a new service pointing to my mxd.
0 Kudos