<?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 Find a specific graphic in GraphicsOverlay in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/find-a-specific-graphic-in-graphicsoverlay/m-p/1190734#M11129</link>
    <description>&lt;P&gt;I have a GraphicsOverlay with &lt;STRONG&gt;&lt;EM&gt;n&lt;/EM&gt; &lt;/STRONG&gt;graphics and I want to find out a number of them with some attributes. Now I have the following code:&lt;/P&gt;&lt;P&gt;for (int i = 0; i &amp;lt; _graphicsOverlay.Graphics.Count(); i++)&lt;BR /&gt;{&lt;BR /&gt;int _index = Convert.ToInt32(_graphicsOverlay.Graphics[i].Attributes["ORDER"].ToString());&lt;BR /&gt;int _range = Convert.ToInt32(_graphicsOverlay.Graphics[i].Attributes["RANGE"].ToString());&lt;BR /&gt;string _type = _graphicsOverlay.Graphics[i].Attributes["TYPE"].ToString();&lt;BR /&gt;if (_index == mapUnits.Order &amp;amp;&amp;amp; _range == range &amp;amp;&amp;amp; _type== "RING")&lt;BR /&gt;{&lt;BR /&gt;_graphicsOverlay.Graphics.Remove(_graphicsOverlay.Graphics[i]);&lt;BR /&gt;return false;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;So, my question is, Is there a better way to get a graphics group &lt;SPAN&gt;that meet certain criteria for certain attributes of the graph?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advance.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 08 Jul 2022 05:49:07 GMT</pubDate>
    <dc:creator>FranciscoLopez</dc:creator>
    <dc:date>2022-07-08T05:49:07Z</dc:date>
    <item>
      <title>Find a specific graphic in GraphicsOverlay</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/find-a-specific-graphic-in-graphicsoverlay/m-p/1190734#M11129</link>
      <description>&lt;P&gt;I have a GraphicsOverlay with &lt;STRONG&gt;&lt;EM&gt;n&lt;/EM&gt; &lt;/STRONG&gt;graphics and I want to find out a number of them with some attributes. Now I have the following code:&lt;/P&gt;&lt;P&gt;for (int i = 0; i &amp;lt; _graphicsOverlay.Graphics.Count(); i++)&lt;BR /&gt;{&lt;BR /&gt;int _index = Convert.ToInt32(_graphicsOverlay.Graphics[i].Attributes["ORDER"].ToString());&lt;BR /&gt;int _range = Convert.ToInt32(_graphicsOverlay.Graphics[i].Attributes["RANGE"].ToString());&lt;BR /&gt;string _type = _graphicsOverlay.Graphics[i].Attributes["TYPE"].ToString();&lt;BR /&gt;if (_index == mapUnits.Order &amp;amp;&amp;amp; _range == range &amp;amp;&amp;amp; _type== "RING")&lt;BR /&gt;{&lt;BR /&gt;_graphicsOverlay.Graphics.Remove(_graphicsOverlay.Graphics[i]);&lt;BR /&gt;return false;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;So, my question is, Is there a better way to get a graphics group &lt;SPAN&gt;that meet certain criteria for certain attributes of the graph?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advance.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2022 05:49:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/find-a-specific-graphic-in-graphicsoverlay/m-p/1190734#M11129</guid>
      <dc:creator>FranciscoLopez</dc:creator>
      <dc:date>2022-07-08T05:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: Find a specific graphic in GraphicsOverlay</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/find-a-specific-graphic-in-graphicsoverlay/m-p/1190891#M11130</link>
      <description>&lt;P&gt;Not sure I understand the&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;return false;&lt;/LI-CODE&gt;&lt;P&gt;inside the conditional, because it will only remove the first one it finds that meets this condition.&lt;/P&gt;&lt;P&gt;I would use LINQ to get a IEnumerable of the graphics I want to remove and then loop through it to do the removals.&amp;nbsp; Again not clear on the purpose of the return, but the below example would return false if anything needed to be removed&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var graphics = _graphicsOverlay.Graphics.Where(g =&amp;gt;
	(int)g.Attributes["ORDER"] == mapUnits.Order &amp;amp;&amp;amp; (int)g.Attributes["RANGE"] == range &amp;amp;&amp;amp;
	g.Attributes["TYPE"].ToString() == "RING");

bool result = true;

foreach (var graphic in graphics)
{
	_graphicsOverlay.Graphics.Remove(graphic);
	result = false;
}

return result;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp; You are going to get an illegal cast exception if either ORDER or RANGE is null.&amp;nbsp; You could do something along these lines to avoid that possibility&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var graphics = _graphicsOverlay.Graphics.Where(g =&amp;gt;
{
	int order = g.Attributes["ORDER"] == null ? 0 : (int)g.Attributes["ORDER"];
	int range = g.Attributes["RANGE"] == null ? 0 : (int)g.Attributes["RANGE"];
	string type = g.Attributes["TYPE"] == null ? string.Empty : g.Attributes["TYPE"].ToString();

	return order == mapUnits.Order &amp;amp;&amp;amp; range == _range &amp;amp;&amp;amp; type == "RING";
});

bool result = true;
foreach (var graphic in graphics)
{
	result = false;
	_graphicsOverlay.Graphics.Remove(graphic);
}

return result;&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 08 Jul 2022 16:26:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/find-a-specific-graphic-in-graphicsoverlay/m-p/1190891#M11130</guid>
      <dc:creator>JoeHershman</dc:creator>
      <dc:date>2022-07-08T16:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: Find a specific graphic in GraphicsOverlay</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/find-a-specific-graphic-in-graphicsoverlay/m-p/1191916#M11134</link>
      <description>&lt;P&gt;Thanks a lot. Now is working perfectly.&lt;/P&gt;&lt;P&gt;The idea of this code is to find out a specific graph, in this case a circle, and move it at a new position instead of to delete it and create a new circle around a point.&lt;/P&gt;&lt;P&gt;The problem now, is that when a move the circle it changes, but the rest of the circles I have in the&amp;nbsp;GraphicsOverlay &amp;nbsp;blink. That is normal?&lt;/P&gt;&lt;P&gt;Here there is the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;private bool ExitGraphicRing(GisStructs.MapUnits mapUnits)&lt;BR /&gt;{&lt;BR /&gt;bool result = false;&lt;BR /&gt;try&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;// New point to move the circle&lt;BR /&gt;MapPoint pointGeometry = new MapPoint(mapUnits.Longitude, mapUnits.Latitude);&lt;BR /&gt;if (_ringRange_GO == null)&lt;BR /&gt;{&lt;BR /&gt;Logger.Error("There is not a GraphicsOverlay for:" + mapUnits.UnitTypes.ToString()); ;&lt;BR /&gt;return result;&lt;BR /&gt;}&lt;BR /&gt;var graphics = _ringRange_GO.Graphics.Where(g =&amp;gt; (int)g.Attributes["ORDER"] == mapUnits.Order &amp;amp;&amp;amp; g.Attributes["TYPE"].ToString() == "RING");&lt;BR /&gt;int x = graphics.Count();&lt;BR /&gt;foreach (var graphic in graphics)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;//RANGE has the diameter of the circle.&lt;BR /&gt;graphic.Geometry = MakeEllipseGeometry(pointGeometry, (int)graphic.Attributes["RANGE"]);&lt;BR /&gt;result = true;&lt;BR /&gt;}&lt;BR /&gt;return result;&lt;BR /&gt;}&lt;BR /&gt;catch (Exception ex)&lt;BR /&gt;{&lt;BR /&gt;Logger.Error("Error:" + ex.Message + "-" + mapUnits.UnitTypes.ToString());&lt;BR /&gt;return result;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2022 14:55:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/find-a-specific-graphic-in-graphicsoverlay/m-p/1191916#M11134</guid>
      <dc:creator>FranciscoLopez</dc:creator>
      <dc:date>2022-07-13T14:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: Find a specific graphic in GraphicsOverlay</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/find-a-specific-graphic-in-graphicsoverlay/m-p/1191919#M11135</link>
      <description>&lt;P&gt;Sorry, I am new and I do not know to use the web side. Here there is the code.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2022 15:00:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/find-a-specific-graphic-in-graphicsoverlay/m-p/1191919#M11135</guid>
      <dc:creator>FranciscoLopez</dc:creator>
      <dc:date>2022-07-13T15:00:43Z</dc:date>
    </item>
  </channel>
</rss>

