<?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: Check if graphic exist at Lat and Long in ArcGIS API for Silverlight Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/check-if-graphic-exist-at-lat-and-long/m-p/225667#M5740</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;There's no method that checks if lat/lon already exist, but you can use Linq query to do that:&lt;BR /&gt;&lt;BR /&gt;The following code checks if any graphic with x/y value exist. Note that the precision need to match in order for this function to return true.&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp; var lon = -140.9;
&amp;nbsp;&amp;nbsp; var lat = 63.391;
&amp;nbsp;&amp;nbsp; var found = l.Graphics.Any(g =&amp;gt; g.Geometry is MapPoint &amp;amp;&amp;amp; Math.Round((g.Geometry as MapPoint).X, 1) == lon
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;&amp;amp; Math.Round((g.Geometry as MapPoint).Y, 3) ==lat);
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks Jennifer! That works great!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 10:59:41 GMT</pubDate>
    <dc:creator>LuisGarcia2</dc:creator>
    <dc:date>2021-12-11T10:59:41Z</dc:date>
    <item>
      <title>Check if graphic exist at Lat and Long</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/check-if-graphic-exist-at-lat-and-long/m-p/225664#M5737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a map where I have a bunch of graphics displayed on a graphics layer. I need to add some new graphics but I don't want to add to a lat/long combination that already has one. Is there any method/function that can do this for me? If not, any suggestion on what is the most efficient way to find out this information?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Aug 2012 18:23:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/check-if-graphic-exist-at-lat-and-long/m-p/225664#M5737</guid>
      <dc:creator>LuisGarcia2</dc:creator>
      <dc:date>2012-08-07T18:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: Check if graphic exist at Lat and Long</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/check-if-graphic-exist-at-lat-and-long/m-p/225665#M5738</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I have a map where I have a bunch of graphics displayed on a graphics layer. I need to add some new graphics but I don't want to add to a lat/long combination that already has one. Is there any method/function that can do this for me? If not, any suggestion on what is the most efficient way to find out this information?&lt;BR /&gt;Thanks!&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Assuming these are points, You could loop through all of your graphics in your GraphicsLayer casting it's the geometry to a MapPoint.&amp;nbsp; take the x/y of the graphic and compare it to the one you want to add.&amp;nbsp; if it's the same then exit your loop.&amp;nbsp; Thus, not adding the point&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Psudo-Code....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For each gra as Graphic in myGraphicsLayer.graphics()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if (trycast(gra,MapPoint).X = YourNewXCoord) and (trycast(gra,MapPoint).Y = YourNewYCoord) Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;exit for&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;end if&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Next&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Aug 2012 22:21:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/check-if-graphic-exist-at-lat-and-long/m-p/225665#M5738</guid>
      <dc:creator>deleted-user-ATjHIWsdQYmT</dc:creator>
      <dc:date>2012-08-07T22:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: Check if graphic exist at Lat and Long</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/check-if-graphic-exist-at-lat-and-long/m-p/225666#M5739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There's no method that checks if lat/lon already exist, but you can use Linq query to do that:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The following code checks if any graphic with x/y value exist. Note that the precision need to match in order for this function to return true.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp; var lon = -140.9; &amp;nbsp;&amp;nbsp; var lat = 63.391; &amp;nbsp;&amp;nbsp; var found = l.Graphics.Any(g =&amp;gt; g.Geometry is MapPoint &amp;amp;&amp;amp; Math.Round((g.Geometry as MapPoint).X, 1) == lon &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;&amp;amp; Math.Round((g.Geometry as MapPoint).Y, 3) ==lat);&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Aug 2012 22:21:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/check-if-graphic-exist-at-lat-and-long/m-p/225666#M5739</guid>
      <dc:creator>JenniferNery</dc:creator>
      <dc:date>2012-08-07T22:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: Check if graphic exist at Lat and Long</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/check-if-graphic-exist-at-lat-and-long/m-p/225667#M5740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;There's no method that checks if lat/lon already exist, but you can use Linq query to do that:&lt;BR /&gt;&lt;BR /&gt;The following code checks if any graphic with x/y value exist. Note that the precision need to match in order for this function to return true.&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp; var lon = -140.9;
&amp;nbsp;&amp;nbsp; var lat = 63.391;
&amp;nbsp;&amp;nbsp; var found = l.Graphics.Any(g =&amp;gt; g.Geometry is MapPoint &amp;amp;&amp;amp; Math.Round((g.Geometry as MapPoint).X, 1) == lon
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;&amp;amp; Math.Round((g.Geometry as MapPoint).Y, 3) ==lat);
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks Jennifer! That works great!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:59:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/check-if-graphic-exist-at-lat-and-long/m-p/225667#M5740</guid>
      <dc:creator>LuisGarcia2</dc:creator>
      <dc:date>2021-12-11T10:59:41Z</dc:date>
    </item>
  </channel>
</rss>

