<?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 Get length of each path of Polyline in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-length-of-each-path-of-polyline/m-p/606834#M56729</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using geometryService.length to get length of Polyline, I would like to get and label each of segments (paths) of the polyline. Does geometryService return the lengths of each of the paths in results? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Jul 2016 02:18:35 GMT</pubDate>
    <dc:creator>JohnPreston</dc:creator>
    <dc:date>2016-07-22T02:18:35Z</dc:date>
    <item>
      <title>Get length of each path of Polyline</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-length-of-each-path-of-polyline/m-p/606834#M56729</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using geometryService.length to get length of Polyline, I would like to get and label each of segments (paths) of the polyline. Does geometryService return the lengths of each of the paths in results? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jul 2016 02:18:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-length-of-each-path-of-polyline/m-p/606834#M56729</guid>
      <dc:creator>JohnPreston</dc:creator>
      <dc:date>2016-07-22T02:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: Get length of each path of Polyline</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-length-of-each-path-of-polyline/m-p/606835#M56730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Based on the REST API documention [&lt;A href="http://resources.arcgis.com/en/help/rest/apiref/lengths.html" title="http://resources.arcgis.com/en/help/rest/apiref/lengths.html"&gt;Lengths (Operation)&lt;/A&gt; ] it should return the length of each path.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jul 2016 06:52:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-length-of-each-path-of-polyline/m-p/606835#M56730</guid>
      <dc:creator>FC_Basson</dc:creator>
      <dc:date>2016-07-22T06:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: Get length of each path of Polyline</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-length-of-each-path-of-polyline/m-p/606836#M56731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you point me to of example to get the values? I'm trying looking at documentation here &lt;A href="https://developers.arcgis.com/javascript/3/jsapi/geometryservice.html#event-lengths-complete" title="https://developers.arcgis.com/javascript/3/jsapi/geometryservice.html#event-lengths-complete"&gt;GeometryService (legacy) | API Reference | ArcGIS API for JavaScript 3.17&lt;/A&gt; but can figure out how to loop through lengths. I've tried&lt;/P&gt;&lt;P&gt;geometryService.on("lengths-complete", function (result) {&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;dojo.forEach(result.result.lengths, function (length) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;alert(length);&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;});&lt;/P&gt;&lt;P&gt;}); but it only returns 1 length.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Jul 2016 20:13:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-length-of-each-path-of-polyline/m-p/606836#M56731</guid>
      <dc:creator>JohnPreston</dc:creator>
      <dc:date>2016-07-23T20:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: Get length of each path of Polyline</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-length-of-each-path-of-polyline/m-p/606837#M56732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tested and it seems that the Lengths operation&amp;nbsp; returns the full length for a multipath polyline geometry.&amp;nbsp; So you would still need to iterate the polyline paths for getting the individual path length. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this to return the polyline path lengths:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var polyLine = new Polyline(...);&amp;nbsp; // the polyline you want path lenghts for
// iterate polyline paths
for (p in polyLine.paths){
&amp;nbsp; var tmpline = new Polyline({
&amp;nbsp;&amp;nbsp;&amp;nbsp; "paths": [polyLine.paths
],
&amp;nbsp;&amp;nbsp;&amp;nbsp; "spatialReference": polyLine.spatialReference
&amp;nbsp; });
&amp;nbsp; // get length for each path from geometry service
&amp;nbsp; getLengths(tmpline);
}

function getLengths(geom){
&amp;nbsp; var lengthParams = new LengthsParameters();
&amp;nbsp; lengthParams.polylines = [geom];
&amp;nbsp; lengthParams.lengthUnit = geomService.UNIT_METER;
&amp;nbsp; lengthParams.geodesic = true;
&amp;nbsp; geomService.lengths(lengthParams, function(result){
&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log(result.lengths[0]);
&amp;nbsp; });
}&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You might need to do some organising of the results to make sure the order is right.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:59:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-length-of-each-path-of-polyline/m-p/606837#M56732</guid>
      <dc:creator>FC_Basson</dc:creator>
      <dc:date>2021-12-12T01:59:56Z</dc:date>
    </item>
  </channel>
</rss>

