<?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: Get coordinates of a free hand drawn polyline by user in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-coordinates-of-a-free-hand-drawn-polyline-by/m-p/39347#M3361</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This might not be the "correct" way to do it, but I wanted to accomplish the same thing and I borrowed from &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/#sample/map_xycoords"&gt;this&lt;/A&gt;&lt;SPAN&gt; sample.&amp;nbsp; Instead of creating a listening event for "onMouseMove" or "onMouseDrag", I listened for a mouse click to start a function that adds the coordinates to an array (make sure to clear the array at the start of the function!).&amp;nbsp; Then you can just add the elements of the array later to your info window or wherever you want them to go.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 22 Jan 2013 12:30:59 GMT</pubDate>
    <dc:creator>BrettGreenfield__DNR_</dc:creator>
    <dc:date>2013-01-22T12:30:59Z</dc:date>
    <item>
      <title>Get coordinates of a free hand drawn polyline by user</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-coordinates-of-a-free-hand-drawn-polyline-by/m-p/39345#M3359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello everybody,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm new here, and I have been using the esri javascript api for about 2 weeks now.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have followed this example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/#sample/graphics_add" rel="nofollow" target="_blank"&gt;http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/#sample/graphics_add&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And I was able to draw a free hand polyline on the map. Now I need to calculate the coordinates of every single point on that polyline. I have been trying to do it for about 3 days now and I can't figure out how to do it. I would appreciate if any of you could explain me how to do it in detail (since I don't have too much experience).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Diego.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jan 2013 15:36:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-coordinates-of-a-free-hand-drawn-polyline-by/m-p/39345#M3359</guid>
      <dc:creator>DiegoCastillo1</dc:creator>
      <dc:date>2013-01-18T15:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: Get coordinates of a free hand drawn polyline by user</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-coordinates-of-a-free-hand-drawn-polyline-by/m-p/39346#M3360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What do you mean 'calculate the coordinates'?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You should have some type of 'onDrawEnd' event handling drawing your graphic feature on the map.&amp;nbsp; In this function you can read the geometry of the graphic and implement whatever custom logic you might need.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Alternatively, you don't have to use this onDrawEnd handler.&amp;nbsp; You should be able to access the graphic geometry at any time through your graphicsLayer methods/properties.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you are using the sample you stated, then inside the addGraphic function you can get access to the polyline coordinates via:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;var polylinePointCollection = geometry.paths;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jan 2013 12:10:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-coordinates-of-a-free-hand-drawn-polyline-by/m-p/39346#M3360</guid>
      <dc:creator>TommyBramble</dc:creator>
      <dc:date>2013-01-22T12:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: Get coordinates of a free hand drawn polyline by user</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-coordinates-of-a-free-hand-drawn-polyline-by/m-p/39347#M3361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This might not be the "correct" way to do it, but I wanted to accomplish the same thing and I borrowed from &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/#sample/map_xycoords"&gt;this&lt;/A&gt;&lt;SPAN&gt; sample.&amp;nbsp; Instead of creating a listening event for "onMouseMove" or "onMouseDrag", I listened for a mouse click to start a function that adds the coordinates to an array (make sure to clear the array at the start of the function!).&amp;nbsp; Then you can just add the elements of the array later to your info window or wherever you want them to go.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jan 2013 12:30:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-coordinates-of-a-free-hand-drawn-polyline-by/m-p/39347#M3361</guid>
      <dc:creator>BrettGreenfield__DNR_</dc:creator>
      <dc:date>2013-01-22T12:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: Get coordinates of a free hand drawn polyline by user</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-coordinates-of-a-free-hand-drawn-polyline-by/m-p/39348#M3362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The user "Juffy" helped me out on the stackoverflow forum, and finally got it to work. Here's how he taught me how to do it, if anyone is interested:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"You need to inspect the geometry object you get from the event onDrawEnd - this event is already being hooked in the example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;dojo.connect(tb, "onDrawEnd", addGraphic);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but all it does is add the line to the map with an basic symbol. The first trap is that the geometry object won't actually be of type geometry - that's an abstract base class that doesn't really exist. The type will depend on what tool you were using to draw the shape - in your case it sounds like it'll be of type Polyline.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This Polyline object has a property paths, which is a nested array of paths (lines), each of which contains an array of points. So if you wanted to get all the points of all the paths in a Polyline object:"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;function addGraphic(geo) { &amp;nbsp;&amp;nbsp;&amp;nbsp; //For each path... &amp;nbsp;&amp;nbsp;&amp;nbsp; for ( var path = 0; path &amp;lt; geo.paths.length; path ++ ) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //For each point in the path... &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for ( var pt = 0; pt &amp;lt; geo.paths[path].length; pt++ ) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Do something with each point in here... &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //X coordinate: geo.paths[path][pt][0] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Y coordinate: geo.paths[path][pt][1] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp; } }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks to you guys for helping me out too!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Diego.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jan 2013 13:46:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-coordinates-of-a-free-hand-drawn-polyline-by/m-p/39348#M3362</guid>
      <dc:creator>DiegoCastillo1</dc:creator>
      <dc:date>2013-01-22T13:46:58Z</dc:date>
    </item>
  </channel>
</rss>

