<?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 QueryTask: graphics not being drawn? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/querytask-graphics-not-being-drawn/m-p/590311#M55162</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to implement a query task in my JS app per this tutorial:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="https://developers.arcgis.com/en/javascript/jshelp/intro_querytask.html" rel="nofollow" target="_blank"&gt;https://developers.arcgis.com/en/javascript/jshelp/intro_querytask.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After a little finagling everything seems to be working fine -- the query returns the expected feature and the callback gets called. But nothing is showing up on the map. Are there any caveats I should know about? This is how I initialize the query, etc.:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;// Initialize query task queryTask = new QueryTask('http://myurl');&amp;nbsp; // Initialize query query = new Query(); query.returnGeometry = true; query.outFields = ['PIND'];&amp;nbsp; // Initialize info template infoTemplate = new InfoTemplate('${PIND}', 'PIND: ${PIND}');&amp;nbsp; // Initialize symbol symbol = new SimpleFillSymbol(&amp;nbsp; SimpleFillSymbol.STYLE_SOLID,&amp;nbsp; new SimpleLineSymbol( &amp;nbsp; SimpleLineSymbol.STYLE_SOLID, &amp;nbsp; new Color([255.0, 0.0, 0.0])&amp;nbsp; ),&amp;nbsp; new Color([255.0, 0.0, 0.0, 0.25]) );&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And this is my drawing function:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;function drawFeatureSet(featureSet) {&amp;nbsp; try { &amp;nbsp; // Clear graphics &amp;nbsp; map.graphics.clear();&amp;nbsp; &amp;nbsp; // Loop through features &amp;nbsp; for (feature in featureSet.features) { &amp;nbsp;&amp;nbsp; feature.symbol = symbol; &amp;nbsp;&amp;nbsp; feature.infoTemplate = infoTemplate; &amp;nbsp;&amp;nbsp; map.graphics.add(feature); &amp;nbsp; }&amp;nbsp; }&amp;nbsp; catch(e) { &amp;nbsp; console.log(e.message);&amp;nbsp; } }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I try logging the contents of the graphics layer after adding all I see is ["0"]. Strange...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 09 Aug 2013 22:41:20 GMT</pubDate>
    <dc:creator>RobertMartin2</dc:creator>
    <dc:date>2013-08-09T22:41:20Z</dc:date>
    <item>
      <title>QueryTask: graphics not being drawn?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/querytask-graphics-not-being-drawn/m-p/590311#M55162</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to implement a query task in my JS app per this tutorial:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="https://developers.arcgis.com/en/javascript/jshelp/intro_querytask.html" rel="nofollow" target="_blank"&gt;https://developers.arcgis.com/en/javascript/jshelp/intro_querytask.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After a little finagling everything seems to be working fine -- the query returns the expected feature and the callback gets called. But nothing is showing up on the map. Are there any caveats I should know about? This is how I initialize the query, etc.:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;// Initialize query task queryTask = new QueryTask('http://myurl');&amp;nbsp; // Initialize query query = new Query(); query.returnGeometry = true; query.outFields = ['PIND'];&amp;nbsp; // Initialize info template infoTemplate = new InfoTemplate('${PIND}', 'PIND: ${PIND}');&amp;nbsp; // Initialize symbol symbol = new SimpleFillSymbol(&amp;nbsp; SimpleFillSymbol.STYLE_SOLID,&amp;nbsp; new SimpleLineSymbol( &amp;nbsp; SimpleLineSymbol.STYLE_SOLID, &amp;nbsp; new Color([255.0, 0.0, 0.0])&amp;nbsp; ),&amp;nbsp; new Color([255.0, 0.0, 0.0, 0.25]) );&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And this is my drawing function:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;function drawFeatureSet(featureSet) {&amp;nbsp; try { &amp;nbsp; // Clear graphics &amp;nbsp; map.graphics.clear();&amp;nbsp; &amp;nbsp; // Loop through features &amp;nbsp; for (feature in featureSet.features) { &amp;nbsp;&amp;nbsp; feature.symbol = symbol; &amp;nbsp;&amp;nbsp; feature.infoTemplate = infoTemplate; &amp;nbsp;&amp;nbsp; map.graphics.add(feature); &amp;nbsp; }&amp;nbsp; }&amp;nbsp; catch(e) { &amp;nbsp; console.log(e.message);&amp;nbsp; } }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I try logging the contents of the graphics layer after adding all I see is ["0"]. Strange...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Aug 2013 22:41:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/querytask-graphics-not-being-drawn/m-p/590311#M55162</guid>
      <dc:creator>RobertMartin2</dc:creator>
      <dc:date>2013-08-09T22:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: QueryTask: graphics not being drawn?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/querytask-graphics-not-being-drawn/m-p/590312#M55163</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;featureSet.features is an array, not an object so doing for ... in isn't applicable. Instead use something like the showResults function from the page you linked to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;function showResults(featureSet) { &amp;nbsp;&amp;nbsp;&amp;nbsp; //remove all graphics on the maps graphics layer &amp;nbsp;&amp;nbsp;&amp;nbsp; map.graphics.clear();&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //Performance enhancer - assign featureSet array to a single variable. &amp;nbsp;&amp;nbsp;&amp;nbsp; var resultFeatures = featureSet.features;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //Loop through each feature returned &amp;nbsp;&amp;nbsp;&amp;nbsp; for (var i=0, il=resultFeatures.length; i&amp;lt;il; i++) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Get the current feature from the featureSet. &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Feature is a graphic &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var graphic = resultFeatures&lt;I&gt;; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; graphic.setSymbol(symbol);&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Set the infoTemplate. &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; graphic.setInfoTemplate(infoTemplate);&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Add graphic to the map graphics layer. &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.graphics.add(graphic); &amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp; }&lt;/I&gt;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also note that setSymbol() method is used rather than setting the symbol property directly.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Aug 2013 23:09:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/querytask-graphics-not-being-drawn/m-p/590312#M55163</guid>
      <dc:creator>derekswingley1</dc:creator>
      <dc:date>2013-08-09T23:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: QueryTask: graphics not being drawn?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/querytask-graphics-not-being-drawn/m-p/590313#M55164</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That must be it! Thanks Derek. I was thinking the for...in would work along the lines of the Python equivalent. I'll try this out.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 10 Aug 2013 18:18:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/querytask-graphics-not-being-drawn/m-p/590313#M55164</guid>
      <dc:creator>RobertMartin2</dc:creator>
      <dc:date>2013-08-10T18:18:44Z</dc:date>
    </item>
  </channel>
</rss>

