<?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 Getting the coordinates of the closest facility in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getting-the-coordinates-of-the-closest-facility/m-p/471846#M43732</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have published a Network Analyst Service that calculates the closest facility (of Point type) to the click performed on the map. I would like to get the coordinates of that Point.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried to do that by exploring the property "facilities" of the solveResult object, but it seems that "facilities" contains all the elements of the layer where the closest facility is calculated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you have any hint?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;closestFacilityTask.solve(params,function(solveResult){
var vente = new esri.Graphic(solveResult.facilities[0]);
venteGraphicsLayer.add(vente);
});&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 27 Apr 2012 12:34:33 GMT</pubDate>
    <dc:creator>ab1</dc:creator>
    <dc:date>2012-04-27T12:34:33Z</dc:date>
    <item>
      <title>Getting the coordinates of the closest facility</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getting-the-coordinates-of-the-closest-facility/m-p/471846#M43732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have published a Network Analyst Service that calculates the closest facility (of Point type) to the click performed on the map. I would like to get the coordinates of that Point.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried to do that by exploring the property "facilities" of the solveResult object, but it seems that "facilities" contains all the elements of the layer where the closest facility is calculated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you have any hint?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;closestFacilityTask.solve(params,function(solveResult){
var vente = new esri.Graphic(solveResult.facilities[0]);
venteGraphicsLayer.add(vente);
});&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Apr 2012 12:34:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getting-the-coordinates-of-the-closest-facility/m-p/471846#M43732</guid>
      <dc:creator>ab1</dc:creator>
      <dc:date>2012-04-27T12:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the coordinates of the closest facility</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getting-the-coordinates-of-the-closest-facility/m-p/471847#M43733</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you saying that you want to retrieve the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;closest &lt;/SPAN&gt;&lt;SPAN&gt; facility from several returned points?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think you could do this by setting returnDirections to true and then examining the esri.tasks.DirectionFeatureSet object that will be returned in ClosestFacilitySolveResult.directions. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can inspect this object for each route to find drive time or route length and map the quickest/shortest result to its corresponding entry in the ClosestFacilitySolveResult.facilities array.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;HTH?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mark Lewin&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 29 Apr 2012 16:46:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getting-the-coordinates-of-the-closest-facility/m-p/471847#M43733</guid>
      <dc:creator>MarkLewin2</dc:creator>
      <dc:date>2012-04-29T16:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the coordinates of the closest facility</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getting-the-coordinates-of-the-closest-facility/m-p/471848#M43734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you Mark for your answer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In fact, I want to retrieve the closest facility from a layer of points. That layer is not returned from any processing. It just exists as a "facilities class" in the NA service that is published in my map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The closest facility analysis is launched when a click on the map is performed. That click generates a point that is stored in the "incidents class".&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Finally, the closest facility analysis looks for the closest feature, in the "features class", to the the point contained in the "incidents class" and returns the routes from the incident to the facility found.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;What I want is to retrieve the point in the "facilities class" found by the closest facility analysis =&amp;gt; the closest facility to the click performed on the map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The object esri.tasks.DirectionFeatureSet doesn't contain the closest facility found by the analysis, nor does the object esri.tasks.ClosestFacilitySolveResult.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 29 Apr 2012 20:48:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getting-the-coordinates-of-the-closest-facility/m-p/471848#M43734</guid>
      <dc:creator>ab1</dc:creator>
      <dc:date>2012-04-29T20:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the coordinates of the closest facility</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getting-the-coordinates-of-the-closest-facility/m-p/471849#M43735</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Has anyone any idea?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 May 2012 20:27:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getting-the-coordinates-of-the-closest-facility/m-p/471849#M43735</guid>
      <dc:creator>ab1</dc:creator>
      <dc:date>2012-05-01T20:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the coordinates of the closest facility</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getting-the-coordinates-of-the-closest-facility/m-p/471850#M43736</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My apologies for the necro-bump, but I'm currently attempting to do this same thing.&amp;nbsp; Is there any way to return either the lat/long or the address of the point so that I can feed it back into the directions widget?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Jul 2016 16:02:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getting-the-coordinates-of-the-closest-facility/m-p/471850#M43736</guid>
      <dc:creator>JimColl</dc:creator>
      <dc:date>2016-07-06T16:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the coordinates of the closest facility</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getting-the-coordinates-of-the-closest-facility/m-p/471851#M43737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Got it, for future google reference, I reached into the output and extracted it by the id like so:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;closestFacilityTask.solve(paramsCF, function(solveResult){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.forEach(solveResult.routes, function(route, index){&lt;/P&gt;&lt;P&gt;&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; var attr = array.map(solveResult.directions[index].features, function(feature){&lt;/P&gt;&lt;P&gt;&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; return feature.attributes.text;&lt;/P&gt;&lt;P&gt;&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; });&lt;/P&gt;&lt;P&gt;&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; route.setAttributes(attr);&lt;/P&gt;&lt;P&gt;&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; destination = route.attributes[route.attributes.length - 1];&lt;/P&gt;&lt;P&gt;&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; destinationArray = destination.split(" ");&lt;/P&gt;&lt;P&gt;&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; destinationId = destinationArray[3];&lt;/P&gt;&lt;P&gt;&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; stopId = +destinationId;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&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; console.log("stopId: ", stopId);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&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; stopPointX = paramsCF.facilities.features[stopId-1].geometry.x;&lt;/P&gt;&lt;P&gt;&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; stopPointY = paramsCF.facilities.features[stopId-1].geometry.y;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&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; stopPoint = new Point(stopPointX, stopPointY);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&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; console.log("stopPoint inside function: ", stopPoint);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&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; // start the directions widget&lt;/P&gt;&lt;P&gt;&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; startDirections();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 10 Jul 2016 05:00:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/getting-the-coordinates-of-the-closest-facility/m-p/471851#M43737</guid>
      <dc:creator>JimColl</dc:creator>
      <dc:date>2016-07-10T05:00:47Z</dc:date>
    </item>
  </channel>
</rss>

