<?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: Trouble display graphics from a GraphicsLayer in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/trouble-display-graphics-from-a-graphicslayer/m-p/741558#M68632</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Glad to help:)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 20 Sep 2013 20:34:32 GMT</pubDate>
    <dc:creator>JasonZou</dc:creator>
    <dc:date>2013-09-20T20:34:32Z</dc:date>
    <item>
      <title>Trouble display graphics from a GraphicsLayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/trouble-display-graphics-from-a-graphicslayer/m-p/741555#M68629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have an application that I'm trying to extend by adding the ability for my users to add a graphic point, line, or polygon and then&amp;nbsp; use that graphic as part of some analysis that I've developed. I'm using &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://developers.arcgis.com/en/javascript/jssamples/graphics_add.html" rel="nofollow" target="_blank"&gt;this sample's code&lt;/A&gt;&lt;SPAN&gt; as the basis for my code to add a user drawn graphic. This all worked fine when it was just adding the graphic to the default map graphics layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Because I wanted to have popups for the graphics that a user adds, I decided that I wanted to create a graphicsLayer to house any user drawn graphics. I've defined the graphicsLayer this way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; var graphicsTemplate = new esri.InfoTemplate();&amp;nbsp; graphicsTemplate.setTitle('Custom Project');&amp;nbsp; graphicsTemplate.setContent(graphicsLayerContent);&amp;nbsp;&amp;nbsp; //Define the Graphics Layer which contains the user drawn "projects"&amp;nbsp; theGLayer = new esri.layers.GraphicsLayer({ &amp;nbsp; id: "gLayer", &amp;nbsp; opacity:0.80, &amp;nbsp; visible:true&amp;nbsp; });&amp;nbsp;&amp;nbsp; theGLayer.setInfoTemplate(graphicsTemplate);&amp;nbsp;&amp;nbsp; map.addLayer(theGLayer);&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Within my application, I've set things up to basically operate like the ESRI sample I linked above. My function to add the graphic that the user draws is the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;function addGraphic(evt) {&amp;nbsp; //deactivate the toolbar and clear existing graphics&amp;nbsp;&amp;nbsp; tb.deactivate();&amp;nbsp;&amp;nbsp; map.enableMapNavigation();&amp;nbsp; theGLayer.clear(); //map.graphics.clear();&amp;nbsp;&amp;nbsp;&amp;nbsp; // figure out which symbol to use&amp;nbsp; var symbol, g;&amp;nbsp; if ( evt.type === "point" || evt.type === "multipoint") { &amp;nbsp; symbol = markerSymbol;&amp;nbsp; } else if ( evt.type === "line" || evt.type === "polyline") { &amp;nbsp; symbol = lineSymbol;&amp;nbsp; }&amp;nbsp; else { &amp;nbsp; symbol = fillSymbol;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; attributes = {"ProjTitle": dojo.attr("intPrjName","value"),"projLimits": dojo.attr("intPrjLimits","value")};&amp;nbsp; g = new esri.Graphic(evt, symbol, attributes, null);&amp;nbsp;&amp;nbsp;&amp;nbsp; theGLayer.add(new esri.Graphic(g)); //map.graphics.add(new esri.Graphic(evt, symbol)); }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My code throws no errors and adds a graphic to the graphicsLayer (theGLayer.graphics.length =1) but it isn't visible. If I add a point, the X,Y coordinates of the stored graphic point match the X,Y coordinates of the evt object and the spatialReference of the graphic matches the spatialReference of the map. Everything tells me that the layer is visible but I don't see my graphics when I add them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What am I missing??&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Sep 2013 20:11:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/trouble-display-graphics-from-a-graphicslayer/m-p/741555#M68629</guid>
      <dc:creator>SteveCole</dc:creator>
      <dc:date>2013-09-20T20:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble display graphics from a GraphicsLayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/trouble-display-graphics-from-a-graphicslayer/m-p/741556#M68630</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;function addGraphic(evt)&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Make sure evt here is a graphic object, not the event object returned from drawToolbar.onDrawEnd event.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Change:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;theGLayer.add(new esri.Graphic(g)); //map.graphics.add(new esri.Graphic(evt, symbol));&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;theGLayer.add(g); &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;g is already a graphic.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Sep 2013 20:24:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/trouble-display-graphics-from-a-graphicslayer/m-p/741556#M68630</guid>
      <dc:creator>JasonZou</dc:creator>
      <dc:date>2013-09-20T20:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble display graphics from a GraphicsLayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/trouble-display-graphics-from-a-graphicslayer/m-p/741557#M68631</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;FINALLY!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks, Jason for catching that. After making the change, everything works like I want it to.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sometimes it certainly pays to have another set of eyes! Thanks again.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Sep 2013 20:32:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/trouble-display-graphics-from-a-graphicslayer/m-p/741557#M68631</guid>
      <dc:creator>SteveCole</dc:creator>
      <dc:date>2013-09-20T20:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble display graphics from a GraphicsLayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/trouble-display-graphics-from-a-graphicslayer/m-p/741558#M68632</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Glad to help:)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Sep 2013 20:34:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/trouble-display-graphics-from-a-graphicslayer/m-p/741558#M68632</guid>
      <dc:creator>JasonZou</dc:creator>
      <dc:date>2013-09-20T20:34:32Z</dc:date>
    </item>
  </channel>
</rss>

