Select to view content in your preferred language

Removing a graphic element from a feature set

1196
3
07-02-2012 07:32 AM
AlaeddineSaadaoui
Regular Contributor
Hi all,
I would like to know how I could remove a graphic element from a feature set.
Thank you.
Tags (2)
0 Kudos
3 Replies
BjornSvensson
Esri Regular Contributor
FeatureSet.features is a normal array, so you can use pop() etc to remove elements from that array.  http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/FeatureSet.html#features

See for example http://resources.arcgis.com/en/help/flex-api/samples/index.html#/Basic_Routing/01nq0000005p000000/
map.defaultGraphicsLayer.remove(stops.features.pop());


"Three methods of the Array class--pop(), shift(), and splice()--allow you to remove elements from an array. The pop() method removes an element from the end of the array. In other words, it removes the element at the highest index number. The shift() method removes an element from the beginning of the array, which means that it always removes the element at index number 0. The splice() method, which can also be used to insert elements, removes an arbitrary number of elements starting at the index number specified by the first argument sent to the method."
http://livedocs.adobe.com/flex/3/html/help.html?content=10_Lists_of_data_2.html
0 Kudos
AlaeddineSaadaoui
Regular Contributor
FeatureSet.features is a normal array, so you can use pop() etc to remove elements from that array.  http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/FeatureSet.html#features

See for example http://resources.arcgis.com/en/help/flex-api/samples/index.html#/Basic_Routing/01nq0000005p000000/
map.defaultGraphicsLayer.remove(stops.features.pop());


"Three methods of the Array class--pop(), shift(), and splice()--allow you to remove elements from an array. The pop() method removes an element from the end of the array. In other words, it removes the element at the highest index number. The shift() method removes an element from the beginning of the array, which means that it always removes the element at index number 0. The splice() method, which can also be used to insert elements, removes an arbitrary number of elements starting at the index number specified by the first argument sent to the method."
http://livedocs.adobe.com/flex/3/html/help.html?content=10_Lists_of_data_2.html

Hi bjorn,
Thank you so much for answering my question. Actually what I want to do is this:
for each (var g:Graphic in featureSet.features)
{
if (g has specific criteria)
    remove it from the featureSet.
}
So I would like to know which of the three methods is the best for this situation.
Thank you very much for your help.
0 Kudos
DasaPaddock
Esri Regular Contributor
0 Kudos