<?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 calculate distance of a point along a polyline (from the origine) ? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-calculate-distance-of-a-point-along-a/m-p/260823#M24149</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did not find an easy way to calculate the distance (from the origine) of a point&amp;nbsp;on a polyline using web app builder (API Javascript 3.25)&lt;/P&gt;&lt;P&gt;I have a polyline with 10 points and a point which is over the polyline.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not want to use a SOE or any server solution to find the distance from the start of the polyline to this point.&lt;/P&gt;&lt;P&gt;I found only one way to do it : (pseudo code) :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;let distance = 0;&lt;/P&gt;&lt;P&gt;let numberOfPoints =&amp;nbsp;myPolyline.paths[0].length;&lt;/P&gt;&lt;P&gt;for (let i = 0 ; i &amp;lt;&amp;nbsp;&lt;SPAN style="background-color: #f6f6f6;"&gt;numberOfPoints&lt;/SPAN&gt;&amp;nbsp;- 1 ; i += 1){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;let myPath = [&lt;SPAN style="background-color: #f6f6f6;"&gt;myPolyline.paths[0]&lt;I&gt;,&amp;nbsp;&lt;SPAN&gt;myPolyline.paths[0][i+1]]&lt;/SPAN&gt;&lt;/I&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;if (this.isMyPointOnMyPath(myPath, myPoint)){&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; distance += this.distanceBetweenTwoPoints(myPolyline.paths[0]&lt;I&gt;, myPoint);&lt;/I&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return distance;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;else {&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;distance += myPath.length;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;return 0.0;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;}&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I think this solution a little bit complex (especially the function&amp;nbsp;&lt;SPAN style="background-color: #f6f6f6;"&gt;&lt;STRONG&gt;isMyPointOnMyPath&amp;nbsp;&lt;/STRONG&gt;where I need to use cross product vector).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Is there an easier way to get the distance using 3.xx javascript API ?&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to find the distance because I need to&amp;nbsp;get a M value of my point on the polyline (&lt;STRONG&gt;I think it's not possible using web app Builder and 3.xx javascript api&lt;/STRONG&gt;).&lt;/P&gt;&lt;P&gt;With my polyline I have two attributes (start M, End M) and it should be easy to get M value of my point.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;best regards,&lt;/P&gt;&lt;P&gt;Sylvain.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Sep 2018 18:53:05 GMT</pubDate>
    <dc:creator>SylvainKerdreux2</dc:creator>
    <dc:date>2018-09-18T18:53:05Z</dc:date>
    <item>
      <title>How to calculate distance of a point along a polyline (from the origine) ?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-calculate-distance-of-a-point-along-a/m-p/260823#M24149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did not find an easy way to calculate the distance (from the origine) of a point&amp;nbsp;on a polyline using web app builder (API Javascript 3.25)&lt;/P&gt;&lt;P&gt;I have a polyline with 10 points and a point which is over the polyline.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not want to use a SOE or any server solution to find the distance from the start of the polyline to this point.&lt;/P&gt;&lt;P&gt;I found only one way to do it : (pseudo code) :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;let distance = 0;&lt;/P&gt;&lt;P&gt;let numberOfPoints =&amp;nbsp;myPolyline.paths[0].length;&lt;/P&gt;&lt;P&gt;for (let i = 0 ; i &amp;lt;&amp;nbsp;&lt;SPAN style="background-color: #f6f6f6;"&gt;numberOfPoints&lt;/SPAN&gt;&amp;nbsp;- 1 ; i += 1){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;let myPath = [&lt;SPAN style="background-color: #f6f6f6;"&gt;myPolyline.paths[0]&lt;I&gt;,&amp;nbsp;&lt;SPAN&gt;myPolyline.paths[0][i+1]]&lt;/SPAN&gt;&lt;/I&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;if (this.isMyPointOnMyPath(myPath, myPoint)){&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; distance += this.distanceBetweenTwoPoints(myPolyline.paths[0]&lt;I&gt;, myPoint);&lt;/I&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return distance;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;else {&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;distance += myPath.length;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;return 0.0;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;}&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I think this solution a little bit complex (especially the function&amp;nbsp;&lt;SPAN style="background-color: #f6f6f6;"&gt;&lt;STRONG&gt;isMyPointOnMyPath&amp;nbsp;&lt;/STRONG&gt;where I need to use cross product vector).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Is there an easier way to get the distance using 3.xx javascript API ?&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to find the distance because I need to&amp;nbsp;get a M value of my point on the polyline (&lt;STRONG&gt;I think it's not possible using web app Builder and 3.xx javascript api&lt;/STRONG&gt;).&lt;/P&gt;&lt;P&gt;With my polyline I have two attributes (start M, End M) and it should be easy to get M value of my point.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;best regards,&lt;/P&gt;&lt;P&gt;Sylvain.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Sep 2018 18:53:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-calculate-distance-of-a-point-along-a/m-p/260823#M24149</guid>
      <dc:creator>SylvainKerdreux2</dc:creator>
      <dc:date>2018-09-18T18:53:05Z</dc:date>
    </item>
  </channel>
</rss>

