<?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: How to get view.goTo to loop through multiple graphics... in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-view-goto-to-loop-through-multiple/m-p/1199123#M78165</link>
    <description>&lt;P&gt;One thing I see is that the line with window.setTimeout should instead be:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;window.setTimeout(stepThroughGraphics.bind(window, view, graphics, index), 2000);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(forgot about that first argument in the call to bind...)&lt;/P&gt;</description>
    <pubDate>Wed, 03 Aug 2022 19:32:55 GMT</pubDate>
    <dc:creator>JoelBennett</dc:creator>
    <dc:date>2022-08-03T19:32:55Z</dc:date>
    <item>
      <title>How to get view.goTo to loop through multiple graphics...</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-view-goto-to-loop-through-multiple/m-p/1199009#M78159</link>
      <description>&lt;P&gt;Hi there...&lt;/P&gt;&lt;P&gt;I'm trying to animate through a set of graphics from a featurelayer. For some reason my code only zooms to the last feature (or, just zooms through all of them so fast it gets to the end).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code I am using:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.whenLayerView(featureLayer).then(function(layerView)
{
   layerView.watch("updating", function(value)
   {
      if (!value)
      {
         // wait for the layer view to finish updating
         if (loading != "done")
         {
            // query all the features available for drawing.
            layerView
               .queryFeatures(
               {
                  geometry: featureLayer.extent,
                  returnGeometry: true
               })
               .then(function(results)
               {
                  graphics = results.features;
                  graphics.forEach(function(result, index)
                  {
                     lat = result.geometry.latitude;
                     lon = result.geometry.longitude;
                     view.goTo(
                     {
                        center: [lon, lat],
                        zoom: 4
                     },
                     {
                        duration: 30000,
                        maxDuration: 30000,
                     })
                  });
                  loading = "done";
               })
               .catch(function(error)
               {
                  console.error("query failed: ", error);
               });
         }
      }
   });
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like the application to zoom to one graphic, wait 2 seconds, then pan over to the next graphic and so on.&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;M&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 16:32:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-view-goto-to-loop-through-multiple/m-p/1199009#M78159</guid>
      <dc:creator>Lake_Country_GIS</dc:creator>
      <dc:date>2022-08-03T16:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to get view.goTo to loop through multiple graphics...</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-view-goto-to-loop-through-multiple/m-p/1199075#M78161</link>
      <description>&lt;P&gt;Perhaps something like the following:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function stepThroughGraphics(view, graphics, index) {
	if (index &amp;lt; graphics.length) {
		var geometry = graphics[index++].geometry;

		view.goTo({
			center: [geometry.longitude, geometry.latitude],
			zoom: 4
		},{
			duration: 30000,
			maxDuration: 30000
		}).then(function() {
			window.setTimeout(stepThroughGraphics.bind(view, graphics, index), 2000);
		});
	} else
		loading = "done";
}

//etc

view.whenLayerView(featureLayer).then(function(layerView) {
	layerView.watch("updating", function(value) {
		if (!value) {
			// wait for the layer view to finish updating
			if (loading != "done") {
				// query all the features available for drawing.
				layerView.queryFeatures({
					geometry: featureLayer.extent,
					returnGeometry: true
				}).then(function(results) {
					stepThroughGraphics(view, results.features, 0);
				}).catch(function(error) {
					console.error("query failed: ", error);
				});
			}
		}
	});
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 18:34:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-view-goto-to-loop-through-multiple/m-p/1199075#M78161</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2022-08-03T18:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to get view.goTo to loop through multiple graphics...</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-view-goto-to-loop-through-multiple/m-p/1199078#M78162</link>
      <description>&lt;P&gt;Thanks. That looks like a good approach...&lt;/P&gt;&lt;P&gt;Seems it zooms to the first feature, then errors out though:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Lake_Country_GIS_0-1659552152349.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/47708i5C8B48613140ACA2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Lake_Country_GIS_0-1659552152349.png" alt="Lake_Country_GIS_0-1659552152349.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Not sure why. Will debug a bit.&lt;/P&gt;&lt;P&gt;Cheers.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 18:42:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-view-goto-to-loop-through-multiple/m-p/1199078#M78162</guid>
      <dc:creator>Lake_Country_GIS</dc:creator>
      <dc:date>2022-08-03T18:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to get view.goTo to loop through multiple graphics...</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-view-goto-to-loop-through-multiple/m-p/1199123#M78165</link>
      <description>&lt;P&gt;One thing I see is that the line with window.setTimeout should instead be:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;window.setTimeout(stepThroughGraphics.bind(window, view, graphics, index), 2000);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(forgot about that first argument in the call to bind...)&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 19:32:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-view-goto-to-loop-through-multiple/m-p/1199123#M78165</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2022-08-03T19:32:55Z</dc:date>
    </item>
  </channel>
</rss>

