<?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 4.0beta using Query task to return graphics and zoom to the graphics in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/4-0beta-using-query-task-to-return-graphics-and/m-p/456040#M42138</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Friends,&lt;/P&gt;&lt;P&gt;I'm facing difficulty in 4.0beta version 3D Screenview to query some features using Query task and features should be zoomed the feature extent.&lt;/P&gt;&lt;P&gt;Anyone can help in this..&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Aug 2015 07:27:04 GMT</pubDate>
    <dc:creator>selvarajkrishnan1</dc:creator>
    <dc:date>2015-08-13T07:27:04Z</dc:date>
    <item>
      <title>4.0beta using Query task to return graphics and zoom to the graphics</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/4-0beta-using-query-task-to-return-graphics-and/m-p/456040#M42138</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Friends,&lt;/P&gt;&lt;P&gt;I'm facing difficulty in 4.0beta version 3D Screenview to query some features using Query task and features should be zoomed the feature extent.&lt;/P&gt;&lt;P&gt;Anyone can help in this..&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 07:27:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/4-0beta-using-query-task-to-return-graphics-and/m-p/456040#M42138</guid>
      <dc:creator>selvarajkrishnan1</dc:creator>
      <dc:date>2015-08-13T07:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: 4.0beta using Query task to return graphics and zoom to the graphics</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/4-0beta-using-query-task-to-return-graphics-and/m-p/456041#M42139</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looking here: &lt;A href="https://developers.arcgis.com/javascript/beta/api-reference/esri-Map.html" title="https://developers.arcgis.com/javascript/beta/api-reference/esri-Map.html"&gt;Map | API Reference | ArcGIS API for JavaScript&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think the zoomt to extent method is implemented yet.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 12:33:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/4-0beta-using-query-task-to-return-graphics-and/m-p/456041#M42139</guid>
      <dc:creator>TimWitt2</dc:creator>
      <dc:date>2015-08-13T12:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: 4.0beta using Query task to return graphics and zoom to the graphics</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/4-0beta-using-query-task-to-return-graphics-and/m-p/456042#M42140</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Selvaraj,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you be a little more specific with your issue? Are you having trouble with QueryTask, zooming to a feature's extent in general? Or only in the SceneView (you get it to work in MapView)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was able to query features using &lt;A href="http://developers.arcgis.com/javascript/beta/sample-code/2d/feature-layer/" rel="nofollow noopener noreferrer" target="_blank"&gt;this sample&lt;/A&gt; as a base. Here is my sample app in a jsbin: &lt;A href="https://jsbin.com/gususohape/edit?html,output" title="https://jsbin.com/gususohape/edit?html,output" rel="nofollow noopener noreferrer" target="_blank"&gt;JS Bin - Collaborative JavaScript Debugging&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are the highlights:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/beta/api-reference/esri-tasks-QueryTask.html" rel="nofollow noopener noreferrer" target="_blank"&gt;QueryTask&lt;/A&gt; - This module essentially works the same as it does in 3.x. The main difference is that it returns a Promise instead of a Deferred, so to get the features you need to use .then(). This also allows you to chain multiple functions, which makes your code easier to read. If you're not familiar with using Promises, I encourage to you read the &lt;A href="https://developers.arcgis.com/javascript/beta/guide/working-with-promises/" rel="nofollow noopener noreferrer" target="_blank"&gt;Working with Promises&lt;/A&gt; page in our SDK.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ZoomTo - This can easily be done using the &lt;A href="https://developers.arcgis.com/javascript/beta/api-reference/esri-views-MapView.html#animateTo" rel="nofollow noopener noreferrer" target="_blank"&gt;animateTo()&lt;/A&gt; method on the view. You can animate to a point, geometry, graphic, ViewPoint, and camera (only in SceneView). In my sample app, I passed in the first graphic returned from the query. You are supposed to be able to animate to an array of graphics or geometries, but I wasn't getting that to work properly in my app. That may be a bug, so I'll look in to it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are the main lines of code you should focus on:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;//Set base parameters of query
&amp;nbsp;&amp;nbsp;&amp;nbsp; var q = new Query({
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; distance: 150,&amp;nbsp; //get features within 150ft of mouse click
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; units: "feet",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnGeometry: true,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; spatialRelationship: "esriSpatialRelIntersects",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outFields: ["*"]
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; view.then(function(){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; view.on("click", qFeatures);
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //Executes a query task based on mouse click
&amp;nbsp;&amp;nbsp;&amp;nbsp; function qFeatures(evt){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; q.geometry = evt.mapPoint;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var qTask = new QueryTask({
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; url: featureLayer.url
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; qTask.execute(q).then(function(response){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return response.features;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }).then(highlightGraphics).then(zoomTo);&amp;nbsp; //chain functions
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; var highlight = new SimpleMarkerSymbol({
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; color: "yellow",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; size: 8,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outline: new SimpleLineSymbol({
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; color: "red",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; width: 8
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; })
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //highlight queried features
&amp;nbsp;&amp;nbsp;&amp;nbsp; function highlightGraphics(graphics){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; resultLayer.clear();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; graphics.forEach(function(item, i){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; item.symbol = highlight;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; resultLayer.add(graphics);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return graphics;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //animateTo those features - This acts like a zoomToExtent method
&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; function zoomTo(features){&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; view.animateTo({
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; target: features[0],&amp;nbsp; //you should be able to pass the entire array here
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; scale: 1200
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does this help? This sample should work in a SceneView as well; although the FeatureLayer rendering doesn't perform great at the moment, but you still should be able to observe the animation to the graphics.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:19:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/4-0beta-using-query-task-to-return-graphics-and/m-p/456042#M42140</guid>
      <dc:creator>KristianEkenes</dc:creator>
      <dc:date>2021-12-11T20:19:49Z</dc:date>
    </item>
  </channel>
</rss>

