Dynamic Legend widget for Flexviewer 2.0

7372
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
CharlesHarris
Emerging Contributor
Can I compile this widget outside of the sample viewer for use with an application that is not based upon the sample viewer?  I would like to use it in a pop up window so that a legend is dynamically drawn in a pop up window when a button is pushed.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Jeremy,

   Nope it is no where near that simple the widget is developed and dependent on the FlexViewer 2.0 framework and will not work independent of it. But I did provide the source code so a developer could look at and copy the code over to a non FV2.0 app.
0 Kudos
CharlesHarris
Emerging Contributor
Ha! Given that I'm that developer and my experience is limited, Where would I start?  I'm trying to display the legend in a panel that pops up as a the user pushes buttons to change between different unique value renders of the same layer.

Thanks for your help!
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Jeremy,

   I you want anything other than general advice like, look at the Renderer.getSymbol and then the Symbol.createSwatch methods than you really need to provide specific details like what code are you using to get access to the renderer, or even better a stripped down sample of what you are attempting with the multiple renderers.
0 Kudos
CharlesHarris
Emerging Contributor
Here is a screenshot of what I have developed so far.  Of course the styling isn't complete as I'm focusing on functionality at the moment.  You will notice the buttons on the left that indicate different "highlights", these are different layers in a published map document.  When the user pushes any one of these buttons the corresponding layer within my map service is turned on and the others are turned off.  You will also notice the panel on the bottom left, this is where the legend will be displayed.  It pops up when any one of the "highlight" buttons are pushed as well.  Of course it will need to change as the different buttons are pushed.  The legend only needs to show the swatches that refer to the layer of the button that is pushed and is active.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Jeremy,

   What is the code behind the buttons for selecting different highlights? We need to get deeper in this than just general site functionality and workflow.
0 Kudos
CharlesHarris
Emerging Contributor
Ah ok...here is a sample of the code that I've trimmed down to only include the parts for switching highlights and displaying panel that will contain the legend.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Jeremy,


   OK is this a ArcGIS 10 Server http://psiws005/PyramidGIS?
0 Kudos
CharlesHarris
Emerging Contributor
Yes...using ArcGIS 10 and ArcGIS API for Flex 2.0 in Flash Builder 4.0
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Jeremy,

   Attached is a zip with the code and a readme.txt in it.
0 Kudos