Select to view content in your preferred language

Clear Everything!!

641
1
10-25-2010 06:05 PM
philippschnetzer
Frequent Contributor
Hi All,

I am wondering about the feasibility of creating a single 'Recycle Bin' button that could be placed in the header area and it would clear absolutely all graphics or selected items with a single click on its icon in the header bar.

Thanks!
Tags (2)
0 Kudos
1 Reply
Drew
by
Frequent Contributor
Hi All,

I am wondering about the feasibility of creating a single 'Recycle Bin' button that could be placed in the header area and it would clear absolutely all graphics or selected items with a single click on its icon in the header bar.

Thanks!


This is quite easy.. Here are the steps and code needed (replace this.map with your map component)

- Loop thought all the map layers and find the all the graphics layers (code below)

[php]

  /**
   * Get all the graphics layers inside the map
   */
  public function GetAllGraphicLayers():ArrayCollection
  {
   var graphicsLayers:ArrayCollection = new ArrayCollection();
   for each(var layer:Layer in this.map.layers)
      {
       if (layer is GraphicsLayer)
       {
        graphicsLayers.addItem(layer);
       }
      }
      return graphicsLayers;
     
  }

[/php]


Then loop through all the graphic layers and clear..
[php]
public function ClearAll():void
  {
   var graphicLayers:ArrayCollection = GetAllGraphicLayers();
   for each(var grapicsLayer:GraphicsLayer in graphicLayers)
      {
    grapicsLayer.clear();
      }
  }
 
[/php]


You could combine all the code i guess but i have it broken out for other reasons.

Drew
0 Kudos