<?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: How to get the coordinates of each vertex of a polygon? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-the-coordinates-of-each-vertex-of-a/m-p/1351454#M82826</link>
    <description>&lt;P&gt;Polygon is using spatial&amp;nbsp; &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Web Mercator coordinate reference system 3857. You will have to transform these coordinates from Web Mercator system to World Geodesic system 4326. I used the following code:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;for (var i = 0; i &amp;lt; gra.geometry.rings.length; i++){
  for (var p = 0; p &amp;lt; gra.geometry.rings[i].length; p++){
    let [x, y] = gra.geometry.rings[i][p];
    let lngLat = webMercatorUtils.xyToLngLat(x,y); //get an array with lng,lat
    vertices.push(lngLat);
  }
}‍‍‍‍‍‍&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 20 Nov 2023 14:29:58 GMT</pubDate>
    <dc:creator>GerardoSevilla</dc:creator>
    <dc:date>2023-11-20T14:29:58Z</dc:date>
    <item>
      <title>How to get the coordinates of each vertex of a polygon?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-the-coordinates-of-each-vertex-of-a/m-p/393075#M36269</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using a webmap. On it I can drop a point or draw a polygon. I can get the coordinates of the point. Now suppose I am drawing a polygon, how can I get the coordinates of each vertex? Please see my code below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;html&amp;gt;&lt;BR /&gt; &amp;lt;head&amp;gt;&lt;BR /&gt; &amp;lt;meta charset="utf-8" /&amp;gt;&lt;BR /&gt; &amp;lt;meta&lt;BR /&gt; name="viewport"&lt;BR /&gt; content="initial-scale=1,maximum-scale=1,user-scalable=no"&lt;BR /&gt; /&amp;gt;&lt;BR /&gt; &lt;BR /&gt;&amp;lt;title&amp;gt;GIS Map for CRM&amp;lt;/title&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;link&lt;BR /&gt; rel="stylesheet"&lt;BR /&gt; href="https://js.arcgis.com/4.14/esri/themes/light/main.css"&lt;BR /&gt; /&amp;gt;&lt;BR /&gt; &amp;lt;script src="https://js.arcgis.com/4.14/"&amp;gt;&amp;lt;/script&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;style&amp;gt;&lt;BR /&gt; html,&lt;BR /&gt; body,&lt;BR /&gt; #viewDiv {&lt;BR /&gt; padding: 0;&lt;BR /&gt; margin: 0;&lt;BR /&gt; height: 100%;&lt;BR /&gt; width: 100%;&lt;BR /&gt; }&lt;BR /&gt; &amp;lt;/style&amp;gt;&lt;BR /&gt; &amp;lt;script&amp;gt;&lt;BR /&gt; //alert("Project ID is equals to 0");&lt;BR /&gt; require(["esri/views/MapView",&lt;BR /&gt; "esri/WebMap", "esri/config",&lt;BR /&gt; "esri/widgets/Sketch",&lt;BR /&gt; "esri/layers/GraphicsLayer"],&lt;/P&gt;&lt;P&gt;function (MapView, WebMap, esriConfig, Sketch, GraphicsLayer) {&lt;/P&gt;&lt;P&gt;esriConfig.portalUrl = "https://portal.environment.gov.za/portal";&lt;BR /&gt; var webmap = new WebMap({&lt;BR /&gt; portalItem: {&lt;BR /&gt; id: "04582be14885483da48f29398960f653"&lt;BR /&gt; }&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;var graphicsLayer = new GraphicsLayer();&lt;/P&gt;&lt;P&gt;var view = new MapView({&lt;BR /&gt; map: webmap,&lt;BR /&gt; //zoom: 14,&lt;BR /&gt; container: "viewDiv"&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;//var symbol = {&lt;BR /&gt; // type: "simple-marker", // autocasts as new SimpleMarkerSymbol()&lt;BR /&gt; // style: "circle",&lt;BR /&gt; // color: "blue",&lt;BR /&gt; // size: "8px", // pixels&lt;BR /&gt; // outline: { // autocasts as new SimpleLineSymbol()&lt;BR /&gt; // color: [255, 255, 0],&lt;BR /&gt; // width: 1 // points&lt;BR /&gt; // }&lt;BR /&gt; //};&lt;/P&gt;&lt;P&gt;webmap.layers.add(graphicsLayer);&lt;/P&gt;&lt;P&gt;var sketch = new Sketch({&lt;BR /&gt; layer: graphicsLayer,&lt;BR /&gt; view: view,&lt;BR /&gt; //symbol: symbol,&lt;BR /&gt; creationMode: "update",&lt;BR /&gt; //availableCreateTools: ["point"]&lt;BR /&gt; //container: "viewDiv"&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;view.ui.add(sketch, {&lt;BR /&gt; position: "top-right"&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;//Listen to sketch widget's create event.&lt;/P&gt;&lt;P&gt;sketch.on('create', function (event) {&lt;BR /&gt; // check if the create event's state has changed to complete indicating&lt;BR /&gt; // the graphic create operation is completed.&lt;BR /&gt; if (event.state === "complete") {&lt;/P&gt;&lt;P&gt;if (view.zoom &amp;gt;= 11) {&lt;BR /&gt; let gra = event.graphic.clone();&lt;BR /&gt; event.graphic.layer.removeAll();&lt;BR /&gt; gra.symbol.color = "red";&lt;BR /&gt; gra.layer.add(gra);&lt;BR /&gt; console.log(view.zoom);&lt;BR /&gt; console.log("X = ", gra.geometry.x);&lt;BR /&gt; console.log("Y = ", gra.geometry.y);&lt;BR /&gt; console.log("Lat = ", event.graphic.geometry.latitude);&lt;BR /&gt; console.log("Long = ", event.graphic.geometry.longitude);&lt;BR /&gt; //lati = event.graphic.geometry.latitude;&lt;BR /&gt; //longi = event.graphic.geometry.longitude;&lt;BR /&gt; zoomLevel = view.zoom;&lt;BR /&gt; debugger;&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; alert("please zoom in");&lt;BR /&gt; event.graphic.layer.remove(event.graphic);&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; });&lt;BR /&gt; });&lt;BR /&gt; &amp;lt;/script&amp;gt;&lt;BR /&gt; &amp;lt;/head&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;body&amp;gt;&lt;BR /&gt; &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;&lt;BR /&gt; &amp;lt;/body&amp;gt;&lt;BR /&gt;&amp;lt;/html&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 May 2020 10:10:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-the-coordinates-of-each-vertex-of-a/m-p/393075#M36269</guid>
      <dc:creator>SiyabongaKubeka</dc:creator>
      <dc:date>2020-05-06T10:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the coordinates of each vertex of a polygon?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-the-coordinates-of-each-vertex-of-a/m-p/393076#M36270</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have to loop through the rings of the polygon.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; i &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; i &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; gra&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;geometry&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;rings&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;length&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; i&lt;SPAN class="operator token"&gt;++&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
  &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; p &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; p &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; gra&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;geometry&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;rings&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;i&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;length&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; p&lt;SPAN class="operator token"&gt;++&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; LatLon &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;String&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;gra&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;geometry&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;rings&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;i&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;p&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍‍
    console&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;log&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;LatLon&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:00:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-the-coordinates-of-each-vertex-of-a/m-p/393076#M36270</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-11T18:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the coordinates of each vertex of a polygon?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-the-coordinates-of-each-vertex-of-a/m-p/393077#M36271</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much Robert, it works.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2020 06:50:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-the-coordinates-of-each-vertex-of-a/m-p/393077#M36271</guid>
      <dc:creator>SiyabongaKubeka</dc:creator>
      <dc:date>2020-05-07T06:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the coordinates of each vertex of a polygon?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-the-coordinates-of-each-vertex-of-a/m-p/1190262#M77863</link>
      <description>&lt;P&gt;I don't get the correct format of longitude and latitude even after using the method provided above&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-07-07 at 1.18.43 PM.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/45416i55B747475D209DAC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2022-07-07 at 1.18.43 PM.png" alt="Screenshot 2022-07-07 at 1.18.43 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 07:48:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-the-coordinates-of-each-vertex-of-a/m-p/1190262#M77863</guid>
      <dc:creator>SaiCharanKoppula</dc:creator>
      <dc:date>2022-07-07T07:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the coordinates of each vertex of a polygon?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-the-coordinates-of-each-vertex-of-a/m-p/1351454#M82826</link>
      <description>&lt;P&gt;Polygon is using spatial&amp;nbsp; &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Web Mercator coordinate reference system 3857. You will have to transform these coordinates from Web Mercator system to World Geodesic system 4326. I used the following code:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;for (var i = 0; i &amp;lt; gra.geometry.rings.length; i++){
  for (var p = 0; p &amp;lt; gra.geometry.rings[i].length; p++){
    let [x, y] = gra.geometry.rings[i][p];
    let lngLat = webMercatorUtils.xyToLngLat(x,y); //get an array with lng,lat
    vertices.push(lngLat);
  }
}‍‍‍‍‍‍&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 14:29:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-the-coordinates-of-each-vertex-of-a/m-p/1351454#M82826</guid>
      <dc:creator>GerardoSevilla</dc:creator>
      <dc:date>2023-11-20T14:29:58Z</dc:date>
    </item>
  </channel>
</rss>

