<?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 HOW TO LOOP WAITING FOR GEOMETRY SERVICE DISTANCE RETURN in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-loop-waiting-for-geometry-service-distance/m-p/33465#M2718</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Situation: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;geometry 1: Point &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;geometry 2: segments (from an array of segments already returned by the call to the geometry service - buffer function)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to loop thru them getting the DISTANCE (again using the GeometryService distance function) just to compare and try to find the closest one... but the call will fire the onDistanceComplete(distance) whenever is done.. how I'm supposed to be waiting for this value efficiently?? just looping while the event is fired?? should I have to use a deferred methodology??&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;basically trying to make something like this works&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for (segm=0; segm = segments.length; segm++)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;geom1 = point&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;geom2 = segments[segm]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;HOW I WAIT FORTHIS RETURN?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;geometryService.distance(distParams, function(distance) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;currDistance= distance});&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//Comparison currentDistance with minDistance&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 26 Jan 2013 13:40:30 GMT</pubDate>
    <dc:creator>WalterEralio</dc:creator>
    <dc:date>2013-01-26T13:40:30Z</dc:date>
    <item>
      <title>HOW TO LOOP WAITING FOR GEOMETRY SERVICE DISTANCE RETURN</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-loop-waiting-for-geometry-service-distance/m-p/33465#M2718</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Situation: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;geometry 1: Point &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;geometry 2: segments (from an array of segments already returned by the call to the geometry service - buffer function)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to loop thru them getting the DISTANCE (again using the GeometryService distance function) just to compare and try to find the closest one... but the call will fire the onDistanceComplete(distance) whenever is done.. how I'm supposed to be waiting for this value efficiently?? just looping while the event is fired?? should I have to use a deferred methodology??&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;basically trying to make something like this works&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for (segm=0; segm = segments.length; segm++)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;geom1 = point&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;geom2 = segments[segm]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;HOW I WAIT FORTHIS RETURN?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;geometryService.distance(distParams, function(distance) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;currDistance= distance});&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//Comparison currentDistance with minDistance&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 Jan 2013 13:40:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-loop-waiting-for-geometry-service-distance/m-p/33465#M2718</guid>
      <dc:creator>WalterEralio</dc:creator>
      <dc:date>2013-01-26T13:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO LOOP WAITING FOR GEOMETRY SERVICE DISTANCE RETURN</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-loop-waiting-for-geometry-service-distance/m-p/33466#M2719</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Walter,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The return of &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/#GeometryService/distance"&gt;Geometry.distance&lt;/A&gt;&lt;SPAN&gt; is a &lt;/SPAN&gt;&lt;A href="http://dojotoolkit.org/reference-guide/1.8/dojo/Deferred.html"&gt;dojo.Deferred&lt;/A&gt;&lt;SPAN&gt; object.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In the code you provided, anything in function(distance){} will always be executed after the return is got (if this request succeeds).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In other words, anything in the function will always wait for the return.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As for looping multiple geometryService.distance requests, try &lt;/SPAN&gt;&lt;A href="http://dojotoolkit.org/reference-guide/1.8/dojo/DeferredList.html"&gt;dojo.DeferredList&lt;/A&gt;&lt;SPAN&gt; . It is a multiple-input version of dojo.Deferred. Its input is a list of geometryService.distance, while the output is a list where each element is a return of each request.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You may also check out this &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/32931-How-to-use-dojo.Deferred-dojo.DeferredList-and-.then"&gt;post&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jerome&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jan 2013 14:49:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-loop-waiting-for-geometry-service-distance/m-p/33466#M2719</guid>
      <dc:creator>JanelYang</dc:creator>
      <dc:date>2013-01-28T14:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO LOOP WAITING FOR GEOMETRY SERVICE DISTANCE RETURN</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-loop-waiting-for-geometry-service-distance/m-p/33467#M2720</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Jerome! will do!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jan 2013 14:54:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-loop-waiting-for-geometry-service-distance/m-p/33467#M2720</guid>
      <dc:creator>WalterEralio</dc:creator>
      <dc:date>2013-01-29T14:54:00Z</dc:date>
    </item>
  </channel>
</rss>

