<?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: Graphic within GraphicLayer is undefined. in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-within-graphiclayer-is-undefined/m-p/621986#M58094</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For 1 graphic in the layer, the below lines error and say it is undefined.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding: 0px;"&gt;highlightGeographyLyr.graphics.getItemAt(0).attributes[0]&lt;/P&gt;&lt;P&gt;highlightGeographyLyr.graphics.getItemAt(0).attributes(0)&lt;/P&gt;&lt;P&gt;highlightGeographyLyr.graphics.getItemAt(0).attributes.id&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 09 Aug 2018 16:28:53 GMT</pubDate>
    <dc:creator>DavidKucharski</dc:creator>
    <dc:date>2018-08-09T16:28:53Z</dc:date>
    <item>
      <title>Graphic within GraphicLayer is undefined.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-within-graphiclayer-is-undefined/m-p/621981#M58089</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a graphics layer that has a graphics length of 2 because I added 3 graphics. When I try to reference the graphicLayer.graphics[0] the system is telling me that it is undefined. If I have 3 graphics why would it be undefined?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Aug 2018 14:14:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-within-graphiclayer-is-undefined/m-p/621981#M58089</guid>
      <dc:creator>DavidKucharski</dc:creator>
      <dc:date>2018-08-09T14:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: Graphic within GraphicLayer is undefined.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-within-graphiclayer-is-undefined/m-p/621982#M58090</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you post the code showing how you define graphicsLayer and add the graphics to it?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Aug 2018 14:18:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-within-graphiclayer-is-undefined/m-p/621982#M58090</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2018-08-09T14:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: Graphic within GraphicLayer is undefined.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-within-graphiclayer-is-undefined/m-p/621983#M58091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;David,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;In the 4.x API the graphics property return a Collection not a flat array like the 3.x API did. SO you have to use collection methods.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;//Old way in 3.x&lt;/SPAN&gt;
graphicLayer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;graphics&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;//New way in 4.x&lt;/SPAN&gt;
graphicLayer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;graphics&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;getItemAt&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:30:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-within-graphiclayer-is-undefined/m-p/621983#M58091</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-12T02:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: Graphic within GraphicLayer is undefined.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-within-graphiclayer-is-undefined/m-p/621984#M58092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The graphicLayer.graphics.getItemAt(0) works to get the graphic. Thank you. One last issue though. I am creating the graphic and adding it to the layer using the below code in bold. At the end I add 'id' as an attribute to uniquely identify it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In another process, directly below, I&amp;nbsp;loop through the graphic layer looking for a&amp;nbsp;graphic with an 'id' value. I am getting errors when trying to access the attributes section.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for (gL = 0; highlightGeographyLyr.graphics.length; gL++) {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;if (highlightGeographyLyr.graphics.getItemAt(gl).attributes[0] == geography) {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;highlightGeographyLyr.remove(highlightGeographyLyr.graphics.getItemAt(gl));&lt;BR /&gt;}&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;function highLightGeography(response)&lt;/STRONG&gt; {&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;// Loop through each of the results and assign a symbol and PopupTemplate&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; // to each so they may be visualized on the map&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; var geography = "";&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; var peakResults = arrayUtils.map(response.features, function (&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; feature) {&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;geography = feature.attributes.ID_;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; // Sets the symbol of each resulting feature to a cone with a&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; // fixed color and width. The height is based on the mountain's elevation&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; feature.symbol = {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; type: "simple-fill", // autocasts as new PointSymbol3D()&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; color: {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; r: 245,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; g: 245,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; b: 245,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; a: 0.5&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; },&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; style: "solid",&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; opacity: 0.2,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; outline: { color: "white", width: 1 }&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; };&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;return feature;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; });&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt; peakResults.attributes = { "id": geography };&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; highlightGeographyLyr.addMany(peakResults);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; }&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Aug 2018 14:47:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-within-graphiclayer-is-undefined/m-p/621984#M58092</guid>
      <dc:creator>DavidKucharski</dc:creator>
      <dc:date>2018-08-09T14:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: Graphic within GraphicLayer is undefined.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-within-graphiclayer-is-undefined/m-p/621985#M58093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;David,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Would it not be length - 1 in your for loop?&lt;/P&gt;&lt;PRE class="language-javascript line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;gL &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; highlightGeographyLyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;graphics&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;length &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; gL&lt;SPAN class="operator token"&gt;++&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Aug 2018 15:00:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-within-graphiclayer-is-undefined/m-p/621985#M58093</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2018-08-09T15:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: Graphic within GraphicLayer is undefined.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-within-graphiclayer-is-undefined/m-p/621986#M58094</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For 1 graphic in the layer, the below lines error and say it is undefined.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding: 0px;"&gt;highlightGeographyLyr.graphics.getItemAt(0).attributes[0]&lt;/P&gt;&lt;P&gt;highlightGeographyLyr.graphics.getItemAt(0).attributes(0)&lt;/P&gt;&lt;P&gt;highlightGeographyLyr.graphics.getItemAt(0).attributes.id&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Aug 2018 16:28:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-within-graphiclayer-is-undefined/m-p/621986#M58094</guid>
      <dc:creator>DavidKucharski</dc:creator>
      <dc:date>2018-08-09T16:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: Graphic within GraphicLayer is undefined.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-within-graphiclayer-is-undefined/m-p/621987#M58095</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P class=""&gt;David,&lt;/P&gt;&lt;P class=""&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp; Strange a Collection is a zero based index and the attributes are an Object so your first line should work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Aug 2018 17:07:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-within-graphiclayer-is-undefined/m-p/621987#M58095</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2018-08-09T17:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: Graphic within GraphicLayer is undefined.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-within-graphiclayer-is-undefined/m-p/621988#M58096</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am actually comparing it in a for loop to the 'geography' which is a variable. The javascript blows up on the compare. In the immediate window, I try to see what the value is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;?&amp;nbsp;&lt;SPAN&gt;highlightGeographyLyr.graphics.getItemAt(gl).attributes[0]&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It gives me a value of {...} in the immediate window so something seems to be there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for (gL = 0; highlightGeographyLyr.graphics.length - 1; gL++) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if (highlightGeographyLyr.graphics.getItemAt(gl).attributes[0] == geography) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; highlightGeographyLyr.remove(highlightGeographyLyr.graphics.getItemAt(gl));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Aug 2018 17:12:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-within-graphiclayer-is-undefined/m-p/621988#M58096</guid>
      <dc:creator>DavidKucharski</dc:creator>
      <dc:date>2018-08-09T17:12:17Z</dc:date>
    </item>
    <item>
      <title>Re: Graphic within GraphicLayer is undefined.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-within-graphiclayer-is-undefined/m-p/621989#M58097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P class=""&gt;David,&lt;/P&gt;&lt;P class=""&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp; So you specify gL as your interator index and then you use gl (all lower case) this is an issue in JavaScript as it is case sensitive&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Aug 2018 17:40:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-within-graphiclayer-is-undefined/m-p/621989#M58097</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2018-08-09T17:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: Graphic within GraphicLayer is undefined.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-within-graphiclayer-is-undefined/m-p/621990#M58098</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you and sorry about the javascript error. It is working now.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Aug 2018 18:50:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphic-within-graphiclayer-is-undefined/m-p/621990#M58098</guid>
      <dc:creator>DavidKucharski</dc:creator>
      <dc:date>2018-08-09T18:50:58Z</dc:date>
    </item>
  </channel>
</rss>

