<?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 Get Graphic attributes without getting Graphics themselves in ArcGIS Runtime SDK for Android Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/get-graphic-attributes-without-getting-graphics/m-p/193299#M1289</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an application where I need to draw many &lt;CODE&gt;Graphics&lt;/CODE&gt; on a map, and detect clicks on them. To make this process efficient, I maintain a bi-directional mapping of graphic IDs and object IDs, so basically given a graphic ID, I can determine which of my objects is represented by that graphic. And given one of my objects, I can tell which graphic on the map is representing it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This takes some initial setup, when the &lt;SPAN style="font-family: monospace;"&gt;Graphics &lt;/SPAN&gt; are first drawn on the map. Unfortunately, you can't obtain the id of a &lt;SPAN style="font-family: monospace;"&gt;Graphics&lt;/SPAN&gt; object with something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: monospace;"&gt;Graphic myGraphic = new Graphic()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: monospace;"&gt;graphicLayer.addGraphic(myGraphic)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: monospace;"&gt;graphic.getId()&lt;/SPAN&gt; (or &lt;SPAN style="font-family: monospace;"&gt;graphic.getUid()&lt;/SPAN&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the methods to get ID and UID both return -1 at this point, which I assume has to do with the immutability of Graphics objects. So what I end up having to do is adding attributes to each graphic that contain the object Id, and then do this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: monospace;"&gt;int[] graphicIds = graphicLayer.getGraphicIds()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: monospace;"&gt;for (int i = 0; i &amp;lt; graphicIds.length; i++){&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Graphic myGraphic = graphicsLayer.getGraphic(graphicIds&lt;I&gt;)&lt;/I&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int objectId = myGraphic.getAttributes().get("MY_OBJECT_ID_KEY")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //create mapping of&amp;nbsp; graphicId &amp;lt;--&amp;gt; objectId &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: monospace;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue with this is that the &lt;CODE&gt;graphicsLayer.getGraphic(int id)&lt;/CODE&gt; method takes a long time, usually from 0.1 - 0.15 seconds. Once we get up to only thirty icons that we need to show on the map, the user will be waiting over three seconds, where the application is completely frozen, since this must be on the UI thread. Is there a way, if you have the graphic id, to get the attributes for a graphic without getting the graphic itself? I'm thinking that might speed up this process. Is there another approach I could take on this problem?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 06 Feb 2016 15:27:28 GMT</pubDate>
    <dc:creator>JeffJohnson2</dc:creator>
    <dc:date>2016-02-06T15:27:28Z</dc:date>
    <item>
      <title>Get Graphic attributes without getting Graphics themselves</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/get-graphic-attributes-without-getting-graphics/m-p/193299#M1289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an application where I need to draw many &lt;CODE&gt;Graphics&lt;/CODE&gt; on a map, and detect clicks on them. To make this process efficient, I maintain a bi-directional mapping of graphic IDs and object IDs, so basically given a graphic ID, I can determine which of my objects is represented by that graphic. And given one of my objects, I can tell which graphic on the map is representing it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This takes some initial setup, when the &lt;SPAN style="font-family: monospace;"&gt;Graphics &lt;/SPAN&gt; are first drawn on the map. Unfortunately, you can't obtain the id of a &lt;SPAN style="font-family: monospace;"&gt;Graphics&lt;/SPAN&gt; object with something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: monospace;"&gt;Graphic myGraphic = new Graphic()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: monospace;"&gt;graphicLayer.addGraphic(myGraphic)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: monospace;"&gt;graphic.getId()&lt;/SPAN&gt; (or &lt;SPAN style="font-family: monospace;"&gt;graphic.getUid()&lt;/SPAN&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the methods to get ID and UID both return -1 at this point, which I assume has to do with the immutability of Graphics objects. So what I end up having to do is adding attributes to each graphic that contain the object Id, and then do this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: monospace;"&gt;int[] graphicIds = graphicLayer.getGraphicIds()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: monospace;"&gt;for (int i = 0; i &amp;lt; graphicIds.length; i++){&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Graphic myGraphic = graphicsLayer.getGraphic(graphicIds&lt;I&gt;)&lt;/I&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int objectId = myGraphic.getAttributes().get("MY_OBJECT_ID_KEY")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //create mapping of&amp;nbsp; graphicId &amp;lt;--&amp;gt; objectId &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: monospace;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue with this is that the &lt;CODE&gt;graphicsLayer.getGraphic(int id)&lt;/CODE&gt; method takes a long time, usually from 0.1 - 0.15 seconds. Once we get up to only thirty icons that we need to show on the map, the user will be waiting over three seconds, where the application is completely frozen, since this must be on the UI thread. Is there a way, if you have the graphic id, to get the attributes for a graphic without getting the graphic itself? I'm thinking that might speed up this process. Is there another approach I could take on this problem?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Feb 2016 15:27:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/get-graphic-attributes-without-getting-graphics/m-p/193299#M1289</guid>
      <dc:creator>JeffJohnson2</dc:creator>
      <dc:date>2016-02-06T15:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: Get Graphic attributes without getting Graphics themselves</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/get-graphic-attributes-without-getting-graphics/m-p/193300#M1290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;bumping this since I asked it over the weekend. Anybody have any input on this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Feb 2016 21:21:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/get-graphic-attributes-without-getting-graphics/m-p/193300#M1290</guid>
      <dc:creator>JeffJohnson2</dc:creator>
      <dc:date>2016-02-09T21:21:37Z</dc:date>
    </item>
  </channel>
</rss>

