<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Remove XY graphics from map using flex list components. in ArcGIS API for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/remove-xy-graphics-from-map-using-flex-list/m-p/350183#M8300</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Robert,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The intent is not for you to write the code for me, I think I can do that myself. I just need a little bit of direction since I have been struggling with this for a while. I will use your code block as a new starting point and will ask more pointed questions if I need to. But I think your code block it will be very helpful.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a bunch.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 04 Feb 2014 16:50:26 GMT</pubDate>
    <dc:creator>KomanDiabate</dc:creator>
    <dc:date>2014-02-04T16:50:26Z</dc:date>
    <item>
      <title>Remove XY graphics from map using flex list components.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/remove-xy-graphics-from-map-using-flex-list/m-p/350179#M8296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am working on a project where I am using a list component to add XY locations to the map. The list I am using has allowMultipleSelection="true" and also has a click event to add the selectedItem XY value to map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;var myGraphicPoint:Graphic = new Graphic(new MapPoint(o.X, o.Y, new SpatialReference(3857)));&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem I am trying to solve is the following when the user click on a selected item, the selectedItem is deselected but I am not able to remove the corresponding graphic from the map. I have tried several different things with no satisfactory results: for example, I have loop through the graphicsLayer and try to remove the graphics but it's not working. Does anybody knows how to do this or point me in the right direction. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Any helps will be appreciate. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Feb 2014 21:54:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/remove-xy-graphics-from-map-using-flex-list/m-p/350179#M8296</guid>
      <dc:creator>KomanDiabate</dc:creator>
      <dc:date>2014-02-03T21:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: Remove XY graphics from map using flex list components.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/remove-xy-graphics-from-map-using-flex-list/m-p/350180#M8297</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Koman,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; It is had to tell what you are doing wrong without some code to check... Are you looping through the graphics in reverse order, i.e. -- not ++? You always need to loop in reverse order when you are removing items from an array that you are looping over.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Feb 2014 11:10:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/remove-xy-graphics-from-map-using-flex-list/m-p/350180#M8297</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2014-02-04T11:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: Remove XY graphics from map using flex list components.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/remove-xy-graphics-from-map-using-flex-list/m-p/350181#M8298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Robert,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;To be honest, I have tried to loop the graphicProvider a while back and it didn't work so I went in a different direction, so I don't really have code to illustrate it but I can try to reproduce it again. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;To answer your question, I am not using reverse looping even though I have seen an example of that somewhere while googling for answer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the new direction I was looking at but that is not working also. Not sure how to approach this. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;From you reply it sounds like I need to explore more the reverse looping idea... Here what I have so far, warning it rough and not working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
protected function nameList_changeHandler(event:IndexChangeEvent):void
{ 
 if(nameList.selectedIndex &amp;gt;= 0)
 {
&amp;nbsp; for(var i:int = 0; i &amp;lt; nameList.dataProvider.length; i++)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; var o:Object = nameList.dataProvider.getItemAt(i);
&amp;nbsp;&amp;nbsp; //trace(o.lastName);
&amp;nbsp;&amp;nbsp; if (o.lastName==nameList.selectedItem.lastName)
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var myGraphicPoint:Graphic = new Graphic(new MapPoint(o.X, o.Y, new SpatialReference(3857)));
&amp;nbsp;&amp;nbsp;&amp;nbsp; myGraphicPoint.symbol = BluDiamont;
&amp;nbsp;&amp;nbsp;&amp;nbsp; addressGL_Select.add(myGraphicPoint)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; else 
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; myGraphicPoint.symbol = sms1;
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; //nameList.dataProvider=null;
&amp;nbsp; }
 }&amp;nbsp; 
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a bunch for helping...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:27:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/remove-xy-graphics-from-map-using-flex-list/m-p/350181#M8298</guid>
      <dc:creator>KomanDiabate</dc:creator>
      <dc:date>2021-12-11T16:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Remove XY graphics from map using flex list components.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/remove-xy-graphics-from-map-using-flex-list/m-p/350182#M8299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Koman,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; There is not much for me to go off of there... I don't have enough time to just sit down and write an sample application for you, so the only advice I can give is that when you figure out your logic for determining if a graphic is to be removed from the Graphics Layer(GL) then you have to loop thought the GL in reverse order removing them:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for(var i:int = myGL.graphicProvider.length - 1; i &amp;gt;= 0; i--) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var gra:Graphic = myGL.graphicProvider&lt;I&gt; as Graphic;
&amp;nbsp;&amp;nbsp;&amp;nbsp; //if some condition is true then remove the graphic from the GL
&amp;nbsp;&amp;nbsp;&amp;nbsp; if(gra.attributes.name == "some name"){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myGL.remove(gra);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}&lt;/I&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:27:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/remove-xy-graphics-from-map-using-flex-list/m-p/350182#M8299</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-11T16:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Remove XY graphics from map using flex list components.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/remove-xy-graphics-from-map-using-flex-list/m-p/350183#M8300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Robert,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The intent is not for you to write the code for me, I think I can do that myself. I just need a little bit of direction since I have been struggling with this for a while. I will use your code block as a new starting point and will ask more pointed questions if I need to. But I think your code block it will be very helpful.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a bunch.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Feb 2014 16:50:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/remove-xy-graphics-from-map-using-flex-list/m-p/350183#M8300</guid>
      <dc:creator>KomanDiabate</dc:creator>
      <dc:date>2014-02-04T16:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: Remove XY graphics from map using flex list components.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/remove-xy-graphics-from-map-using-flex-list/m-p/350184#M8301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;FYI: I found another way to do this...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think I was over thinking this one. So what I am doing here is to capture all the selected items in the list component into an arrayCollection and I then clear all the graphisc and re-add them. They are probably a better way to do this but, this is going to do it for me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
protected function nameList_changeHandler(event:IndexChangeEvent):void
{ 
 var selIndices:Vector.&amp;lt;int&amp;gt; = event.currentTarget.selectedIndices;
 var selItems:Vector.&amp;lt;Object&amp;gt; = event.currentTarget.selectedItems;
 var numItems:Number = selIndices.length;
 var myGraphicPoint:Graphic;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
 //Clear GraphicsLayer
 addressGL_Select.clear();
 for (var ix:Number = 0; ix&amp;lt;numItems; ix++)
 {
&amp;nbsp; var cl:ArrayCollection=new ArrayCollection;
&amp;nbsp; cl.addItem(selItems[ix]);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; //CL and Add to Map
&amp;nbsp; for(var i:int = 0; i &amp;lt; cl.length; i++)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; var o:Object = cl.getItemAt(i);
&amp;nbsp;&amp;nbsp; myGraphicPoint = new Graphic(new MapPoint(o.X, o.Y, new SpatialReference(3857)));
&amp;nbsp;&amp;nbsp; myGraphicPoint.symbol = BluDiamont;
&amp;nbsp;&amp;nbsp; addressGL_Select.add(myGraphicPoint);
&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
 } 
 selectList.addItem(nameList.selectedItem);
}
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:27:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/remove-xy-graphics-from-map-using-flex-list/m-p/350184#M8301</guid>
      <dc:creator>KomanDiabate</dc:creator>
      <dc:date>2021-12-11T16:27:58Z</dc:date>
    </item>
  </channel>
</rss>

