<?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 R in Java Maps SDK Questions</title>
    <link>https://community.esri.com/t5/java-maps-sdk-questions/r/m-p/666686#M2038</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using the latest ArcGIS Runtime SDK for Java, I wanted to find a API call to calculate the number of&amp;nbsp;&lt;SPAN style="color: #222222; background-color: #ffffff;"&gt;pixels between 2 points on a map.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 30 Aug 2019 21:13:17 GMT</pubDate>
    <dc:creator>RickSanders1</dc:creator>
    <dc:date>2019-08-30T21:13:17Z</dc:date>
    <item>
      <title>R</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/r/m-p/666686#M2038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using the latest ArcGIS Runtime SDK for Java, I wanted to find a API call to calculate the number of&amp;nbsp;&lt;SPAN style="color: #222222; background-color: #ffffff;"&gt;pixels between 2 points on a map.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Aug 2019 21:13:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/r/m-p/666686#M2038</guid>
      <dc:creator>RickSanders1</dc:creator>
      <dc:date>2019-08-30T21:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: R</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/r/m-p/666687#M2039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's just a case of converting your map coordinates to screen coordinates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is actually very common to convert from screen coordinates and move to map coordinates when you listen into click events. &amp;nbsp;I've shown this in the code below with an extra line of code to convert to back again:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #9876aa;"&gt;mapView&lt;/SPAN&gt;.setOnMouseClicked(e-&amp;gt; {
  &lt;SPAN style="color: #808080;"&gt;// display the screen coordinate
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;  &lt;/SPAN&gt;Point2D screenPoint = &lt;SPAN style="color: #cc7832;"&gt;new &lt;/SPAN&gt;Point2D(e.getX()&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;e.getY())&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;  &lt;/SPAN&gt;System.&lt;SPAN style="color: #9876aa;"&gt;out&lt;/SPAN&gt;.println(&lt;SPAN style="color: #6a8759;"&gt;"screen " &lt;/SPAN&gt;+ screenPoint.getX() +&lt;SPAN style="color: #6a8759;"&gt;"," &lt;/SPAN&gt;+ screenPoint.getY() )&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;  &lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;// convert the screen coordinate to map coordinate
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;  &lt;/SPAN&gt;Point actualPoint = &lt;SPAN style="color: #9876aa;"&gt;mapView&lt;/SPAN&gt;.screenToLocation(screenPoint)&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;  &lt;/SPAN&gt;System.&lt;SPAN style="color: #9876aa;"&gt;out&lt;/SPAN&gt;.println(&lt;SPAN style="color: #6a8759;"&gt;"actual point " &lt;/SPAN&gt;+ actualPoint.getX() +&lt;SPAN style="color: #6a8759;"&gt;"," &lt;/SPAN&gt;+ actualPoint.getY())&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;  &lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;// convert the map coordinate back to the screen coordinate
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;  &lt;/SPAN&gt;Point2D calcScreenPoint = &lt;SPAN style="color: #9876aa;"&gt;mapView&lt;/SPAN&gt;.locationToScreen(actualPoint)&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;  &lt;/SPAN&gt;System.&lt;SPAN style="color: #9876aa;"&gt;out&lt;/SPAN&gt;.println(&lt;SPAN style="color: #6a8759;"&gt;"calc screen point " &lt;/SPAN&gt;+ calcScreenPoint.getX() + &lt;SPAN style="color: #6a8759;"&gt;"," &lt;/SPAN&gt;+ calcScreenPoint.getY())&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;})&lt;SPAN style="color: #cc7832;"&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So if you have 2 map coordinates and convert these to screen coordinates it's just simple maths to work out the number of pixels between the 2 points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note the import statements so you get the types correct:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #cc7832;"&gt;import &lt;/SPAN&gt;com.esri.arcgisruntime.geometry.Point&lt;SPAN style="color: #cc7832;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;import &lt;/SPAN&gt;javafx.geometry.Point2D&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does this help?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:10:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/r/m-p/666687#M2039</guid>
      <dc:creator>MarkBaird</dc:creator>
      <dc:date>2021-12-12T04:10:32Z</dc:date>
    </item>
  </channel>
</rss>

