Select to view content in your preferred language

Create a legend from the real symbol object

572
3
07-22-2010 06:56 AM
Ganael_Jatteau
Emerging Contributor
Hi,

I'm trying to use an Esri symbol object to create a legend (basically display some small rectangles with a border and a fill color). I'm wandering why this solution doesn't work:

var vgroup:VGroup = new VGroup();
for each(var symbol:Symbol in symbols)
{
    var ring:Array = new Array();
    ring.push(new MapPoint(0,0));
    ring.push(new MapPoint(0,5));
    ring.push(new MapPoint(5,5));
    ring.push(new MapPoint(5,0));
    var geometry:Geometry = new Polygon(ring);
    var graphic:Graphic = new Graphic(geometry, symbol);
    vgroup.addElement(graphic);
}

Some elements are added into the vgroup but it appears empty. In other words, how can I display a com.esri.ags.Graphic outside of a Map ?

Thanks in advance !
Tags (2)
0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus
Ganael,

   Look at this thread http://forums.esri.com/Thread.asp?c=158&f=2421&t=286171&mc=2#msgid890328

I am telling someone how to get an image from a symbol but you could skip that portion and just add the uicomponent to your vbox.
0 Kudos
Ganael_Jatteau
Emerging Contributor
Thank you Robert, it works perfectly !

It is a good idea to use the method draw() on a symbol. It can be used to do all kind of drawing outside of a map.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Ganael,

   In the 2.0 API there is a createSwatch method that is made just for what you are doing.
0 Kudos