<?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: coordinates to screen position in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinates-to-screen-position/m-p/1320362#M82030</link>
    <description>&lt;P&gt;If you're wanting to get the map coordinates of the bottom-right point, it would be better to calculate from the pre-existing "screenPoint" variable instead:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var bottomrightX = screenPoint.x + 200  //200 is the width of the box pre css
var bottomrightY = screenPoint.y + 300 //300 is the height of the box per&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For consistency, you also might want to use the same coordinate system in your call to console.log:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;console.log("POINT = " + ptUpdate.longitude + "," + ptUpdate.latitude);&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 18 Aug 2023 23:16:32 GMT</pubDate>
    <dc:creator>JoelBennett</dc:creator>
    <dc:date>2023-08-18T23:16:32Z</dc:date>
    <item>
      <title>coordinates to screen position</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinates-to-screen-position/m-p/1319914#M82015</link>
      <description>&lt;P&gt;Hello all.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to place programmatically a div on the screen and I need its top left corner to be at a certain coordinate location (Lat/Long). How do I calculate the div's left and top property (in px) based on the lat/long?&lt;/P&gt;&lt;P&gt;So, what I am looking for is convert lat/long to px, so I can set the div's left and top position.&lt;/P&gt;&lt;P&gt;I tried this but didn't work.&lt;/P&gt;&lt;P&gt;div's id is "box"&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const screenPoint = view.toScreen(point);
 document.getElementById('box').style.position = "absolute"
 document.getElementById('box').style.left = screenPoint.x +"px"
 document.getElementById('box').style.top = screenPoint.y+"px"&lt;/LI-CODE&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 22:52:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinates-to-screen-position/m-p/1319914#M82015</guid>
      <dc:creator>LefterisKoumis</dc:creator>
      <dc:date>2023-08-17T22:52:58Z</dc:date>
    </item>
    <item>
      <title>Re: coordinates to screen position</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinates-to-screen-position/m-p/1319919#M82016</link>
      <description>&lt;P&gt;This appears to work:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var screenPoint = view.toScreen(point);

var rect = view.container.getBoundingClientRect();
var left = screenPoint.x + rect.left + window.scrollX;
var top = screenPoint.y + rect.top + window.scrollY;

var box = document.getElementById("box");
box.style.position = "absolute";
box.style.left = left.toString() + "px";
box.style.top = top.toString() + "px";&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 17 Aug 2023 23:16:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinates-to-screen-position/m-p/1319919#M82016</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2023-08-17T23:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: coordinates to screen position</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinates-to-screen-position/m-p/1319938#M82017</link>
      <description>&lt;P&gt;I understand the logic but I am missing something.&lt;/P&gt;&lt;P&gt;See this codepen. It works if I set the let, top properties in the css. The ultimate goal for me is to be able to get the extent of the box based on its upper left corner (point) and its width/height. Thank you.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://codepen.io/lkoumis1/pen/QWzWNLQ?editors=1100" target="_blank"&gt;https://codepen.io/lkoumis1/pen/QWzWNLQ?editors=1100&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2023 00:29:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinates-to-screen-position/m-p/1319938#M82017</guid>
      <dc:creator>LefterisKoumis</dc:creator>
      <dc:date>2023-08-18T00:29:35Z</dc:date>
    </item>
    <item>
      <title>Re: coordinates to screen position</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinates-to-screen-position/m-p/1319942#M82018</link>
      <description>&lt;P&gt;The point declaration is invalid, and it also needs to be wrapped in view.when:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.when(function() {
	var point = new Point({x:-121.755, y:38.359});
	var screenPoint = view.toScreen(point);

	var rect = view.container.getBoundingClientRect();
	var left = screenPoint.x + rect.left + window.scrollX;
	var top = screenPoint.y + rect.top + window.scrollY;

	var box = document.getElementById("box");
	box.style.position = "absolute";
	box.style.left = left.toString() + "px";
	box.style.top = top.toString() + "px";
});&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 18 Aug 2023 00:47:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinates-to-screen-position/m-p/1319942#M82018</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2023-08-18T00:47:49Z</dc:date>
    </item>
    <item>
      <title>Re: coordinates to screen position</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinates-to-screen-position/m-p/1320143#M82024</link>
      <description>&lt;P&gt;Just follow up to the above. I updated the codepen&lt;/P&gt;&lt;P&gt;&lt;A href="https://codepen.io/lkoumis1/pen/QWzWNLQ" target="_blank"&gt;https://codepen.io/lkoumis1/pen/QWzWNLQ&lt;/A&gt;&lt;/P&gt;&lt;P&gt;to capture the coords of the bottom right of the box (opposite&amp;nbsp; corner of the point). But the coords widget shows that the recorded coords&amp;nbsp; (shown in console.log) for the bottom right are not matching the widget's display.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2023 15:39:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinates-to-screen-position/m-p/1320143#M82024</guid>
      <dc:creator>LefterisKoumis</dc:creator>
      <dc:date>2023-08-18T15:39:14Z</dc:date>
    </item>
    <item>
      <title>Re: coordinates to screen position</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinates-to-screen-position/m-p/1320362#M82030</link>
      <description>&lt;P&gt;If you're wanting to get the map coordinates of the bottom-right point, it would be better to calculate from the pre-existing "screenPoint" variable instead:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var bottomrightX = screenPoint.x + 200  //200 is the width of the box pre css
var bottomrightY = screenPoint.y + 300 //300 is the height of the box per&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For consistency, you also might want to use the same coordinate system in your call to console.log:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;console.log("POINT = " + ptUpdate.longitude + "," + ptUpdate.latitude);&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 18 Aug 2023 23:16:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinates-to-screen-position/m-p/1320362#M82030</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2023-08-18T23:16:32Z</dc:date>
    </item>
  </channel>
</rss>

