Select to view content in your preferred language

Dynamic Legend

1457
3
08-24-2010 02:45 PM
DanJensen
Deactivated User
In reviewing the information available on this forum it seems that the promise of dynamic legends is achievable using the new createSwatch() method. However, I am having trouble getting a handle on the symbols used by the map service. Of course defining the symbol programatically would not be dynamic, it must come from the map service. This seems to be a little more tricky, at least for me. Can anyone point me in the right direction or provide an example?

Thanks,
-Dan
Tags (2)
0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus
danj,

   Here is a link to a Dynamic Legend Widget for the FlexViewer2.0 that utilizes the createSwatch method so even if you are not using the FlexViewer2.0 you can still look at my code and see how to do it for yourself.

http://www.arcgis.com/home/item.html...b557bf64136af6
0 Kudos
DanJensen
Deactivated User
OK let's start with these two points.

Mr. Scheitlin mentioned his widget requires ArcGIS Server 10.  I soppose this is because earlier versions of AGS do not return objects necessary to use the createSwatch function.  I noticed when trying to implement my own code that drawingInfo returns null.  My suspicion is that ArcGIS Server 9.3.1 can not return a DrawingInfo object which means people like myself cannot use createSwatch on map service layers until we upgrade.  Can anyone confirm my suspicion?  If that is the case what are the alternatives?

Second, I am not knowlegable enough to understand this line of code from Mr. Scheitlin's example.
ArcGISDynamicMapServiceLayer(layer).addEventListener(DetailsEvent.GET_ALL_DETAILS_COMPLETE,function(event:DetailsEvent):void{getAllDetailsResult(event,lname)});

Could someone please break this down for me?

Much appreciated,
-Dan
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Dan,

   Yep, you need ArcGIS Server 10 to use drawingInfos.

Let's break down what this line is doing
ServiceLayer(layer).addEventListener(DetailsEvent.GET_ALL_DETAILS_COMPLETE,function(event:DetailsEvent):void{getAllDetailsResult(event,lname)});


Basically I am adding an event listener to the layer that is listening for the GET_ALLDETAILS_COMPLETE event.

The GET_ALLDETAILS_COMPLETE is needed to get the layerDetails objects from all the layers in the map service for that layer, because LayerDetails is where drawinginfos come from.

So once the event is fired I launch a function called getAllDetailsResult and pass is not only the results of the GET_ALLDETAILS_COMPLETE but also a variable called lname. This inline function trick is what developers use when they want a send something along with the original event dispatcher.
0 Kudos