<?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: Trying to add graphic to query result in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-graphic-to-query-result/m-p/277593#M25611</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ian,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't believe you will be able to pass an object to the geometry property of the Graphic class.&amp;nbsp; You can iterate through the features array of the object and then apply the highlight symbol to each feature.&amp;nbsp; Ex:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;function highlightResults(results){
&amp;nbsp; array.map(results.features, function (result) {
&amp;nbsp;&amp;nbsp; var graphic = result;
&amp;nbsp;&amp;nbsp; graphic.setSymbol(pointHighlightSymbol);
&amp;nbsp;&amp;nbsp; map.graphics.add(graphic);
&amp;nbsp; });

&amp;nbsp; var resultExtent = graphicsUtils.graphicsExtent(results.features);&amp;nbsp; 
&amp;nbsp; map.setExtent(resultExtent.expand(2)); 

}&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a &lt;A href="http://jsfiddle.net/oyaf9rk0/" rel="nofollow noopener noreferrer" target="_blank"&gt;JS Fiddle&lt;/A&gt; that demonstrates this.&amp;nbsp; After clicking on a county, the cities within the county will be selected and then zoomed to.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 13:30:50 GMT</pubDate>
    <dc:creator>JakeSkinner</dc:creator>
    <dc:date>2021-12-11T13:30:50Z</dc:date>
    <item>
      <title>Add graphic to query result</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-graphic-to-query-result/m-p/277592#M25610</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have some code that zooms to a query result extent, but I also want to highlight the query result. Console shows I'm returning an object but i cant seem to add the "highlightSymbol" to it. Any help is much appreciated:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp; //Highlight Symbol
&amp;nbsp; var highlightSymbol = new SimpleFillSymbol(
&amp;nbsp; SimpleFillSymbol.STYLE_SOLID,
&amp;nbsp; new SimpleLineSymbol(
&amp;nbsp; SimpleLineSymbol.STYLE_SOLID,
&amp;nbsp; new Color([255, 0, 0]), 3),
&amp;nbsp; new Color([125, 125, 125, 0.2]));

&amp;nbsp; //Query BLOCK/LOT
&amp;nbsp; var queryTask = new QueryTask(parcels.url);

&amp;nbsp; var query = new Query();
&amp;nbsp; query.returnGeometry = true;
&amp;nbsp; query.outFields = ["*"];
&amp;nbsp; on(dom.byId("execute"), "click", execute);

&amp;nbsp; function execute() {
&amp;nbsp; map.graphics.clear();

&amp;nbsp; query.where = "SSN = '" + dijit.byId("muniSelect").value + "' AND BLOCK = '" + dom.byId("block").value + "' AND LOT = '" + dom.byId("lot").value + "'";
&amp;nbsp; queryTask.execute(query, showResults);
&amp;nbsp; }
&amp;nbsp; function showResults(results) {
&amp;nbsp; var resultItems = [];
&amp;nbsp; var resultCount = results.features.length;
&amp;nbsp; for (var i = 0; i &amp;lt; resultCount; i++) {
&amp;nbsp; var featureAttributes = results.features&lt;I&gt;.attributes;&lt;/I&gt;
&amp;nbsp; for (var attr in featureAttributes) {
&amp;nbsp; resultItems.push("&amp;lt;b&amp;gt;" + attr + ":&amp;lt;/b&amp;gt;&amp;nbsp; " + featureAttributes[attr] + "&amp;lt;br&amp;gt;");
&amp;nbsp; }
&amp;nbsp; resultItems.push("&amp;lt;br&amp;gt;");
&amp;nbsp; }
&amp;nbsp; if (resultCount === 0) {
&amp;nbsp; dom.byId("info").innerHTML = "&amp;lt;h3 style = 'color:#E60000'&amp;gt; No Record Found &amp;lt;/h1&amp;gt;";
&amp;nbsp; } else {
&amp;nbsp; dom.byId("info").innerHTML = resultItems.join("");

&amp;nbsp; //Zoom to Result &amp;amp; Set Query Result Symbol
&amp;nbsp; var resultGraphic = new Graphic(results.features, highlightSymbol);
&amp;nbsp; var resultExtent = graphicsUtils.graphicsExtent(results.features);
&amp;nbsp; map.graphics.add(resultGraphic);
&amp;nbsp; map.setExtent(resultExtent.expand(2));

&amp;nbsp; console.log("resultGraphic:", (results.features));
&amp;nbsp; }
&amp;nbsp; }&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:30:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-graphic-to-query-result/m-p/277592#M25610</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T13:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to add graphic to query result</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-graphic-to-query-result/m-p/277593#M25611</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ian,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't believe you will be able to pass an object to the geometry property of the Graphic class.&amp;nbsp; You can iterate through the features array of the object and then apply the highlight symbol to each feature.&amp;nbsp; Ex:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;function highlightResults(results){
&amp;nbsp; array.map(results.features, function (result) {
&amp;nbsp;&amp;nbsp; var graphic = result;
&amp;nbsp;&amp;nbsp; graphic.setSymbol(pointHighlightSymbol);
&amp;nbsp;&amp;nbsp; map.graphics.add(graphic);
&amp;nbsp; });

&amp;nbsp; var resultExtent = graphicsUtils.graphicsExtent(results.features);&amp;nbsp; 
&amp;nbsp; map.setExtent(resultExtent.expand(2)); 

}&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a &lt;A href="http://jsfiddle.net/oyaf9rk0/" rel="nofollow noopener noreferrer" target="_blank"&gt;JS Fiddle&lt;/A&gt; that demonstrates this.&amp;nbsp; After clicking on a county, the cities within the county will be selected and then zoomed to.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:30:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-graphic-to-query-result/m-p/277593#M25611</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T13:30:50Z</dc:date>
    </item>
  </channel>
</rss>

