<?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 AGSMapView.locationToScreen returns (nan,nan) in ArcGIS Runtime SDK for iOS Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/agsmapview-locationtoscreen-returns-nan-nan/m-p/462627#M3961</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My app displays spatially accurate graphics in a view on top of the mapView. To do so, I perform&amp;nbsp;on-the-fly transformations for the graphics from within&amp;nbsp;viewpointChangedHandler. Sometimes on first load, some of the graphics don't show on the screen where they should. After much debugging, I have discovered that even though the mapView.map has been loaded, calling mapView.locationToScreen() returns a CGPoint where both x and y are NaN, CGPoint(x: nan, y: nan).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The map is already AGSLoadStatusLoaded. But obviously, I'm trying to do this too soon. What trigger or observable on the mapView or mapView.map can I use to know when mapView.locationToScreen is ready to return good screen coordinates?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 Feb 2018 23:27:13 GMT</pubDate>
    <dc:creator>WorthSparks</dc:creator>
    <dc:date>2018-02-02T23:27:13Z</dc:date>
    <item>
      <title>AGSMapView.locationToScreen returns (nan,nan)</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/agsmapview-locationtoscreen-returns-nan-nan/m-p/462627#M3961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My app displays spatially accurate graphics in a view on top of the mapView. To do so, I perform&amp;nbsp;on-the-fly transformations for the graphics from within&amp;nbsp;viewpointChangedHandler. Sometimes on first load, some of the graphics don't show on the screen where they should. After much debugging, I have discovered that even though the mapView.map has been loaded, calling mapView.locationToScreen() returns a CGPoint where both x and y are NaN, CGPoint(x: nan, y: nan).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The map is already AGSLoadStatusLoaded. But obviously, I'm trying to do this too soon. What trigger or observable on the mapView or mapView.map can I use to know when mapView.locationToScreen is ready to return good screen coordinates?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Feb 2018 23:27:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/agsmapview-locationtoscreen-returns-nan-nan/m-p/462627#M3961</guid>
      <dc:creator>WorthSparks</dc:creator>
      <dc:date>2018-02-02T23:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: AGSMapView.locationToScreen returns (nan,nan)</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/agsmapview-locationtoscreen-returns-nan-nan/m-p/462628#M3962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In case anyone needs a workaround, this is what worked for me. It is crude, I know. But it works even on an iPhone 5s, which is the slowest device my app will run on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;self&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;map &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;AGSMap&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;item&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; portalItem&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
self&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;map&lt;SPAN class="operator token"&gt;?&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;load &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;_ in
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;// Even after the map load has completed, self.map is not ready&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;// for any locationToScreen calls yet.&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Timer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;scheduledTimer&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;withTimeInterval&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0.5&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; repeats&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; false&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;_ in
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;// But after waiting half a second, in all my tests, it is ready.&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;// The following line triggers sketchView.draw(CGRect), which&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;// calls this mapView's locationToScreen several times in pursuit&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;// of sketch stroke transformations.&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;sketchView&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;setNeedsDisplay&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &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;/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;P&gt;&lt;/P&gt;&lt;P&gt;I'm not too keen on relying on a Timer for the solution.&amp;nbsp;I'm hoping someone can tell me a better way.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:33:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/agsmapview-locationtoscreen-returns-nan-nan/m-p/462628#M3962</guid>
      <dc:creator>WorthSparks</dc:creator>
      <dc:date>2021-12-11T20:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: AGSMapView.locationToScreen returns (nan,nan)</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/agsmapview-locationtoscreen-returns-nan-nan/m-p/462629#M3963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try observing the AGSMapView#spatialReference property and wait till it is initialized. That should signal that the mapview has been properly setup to work with the provided map.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Feb 2018 20:15:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/agsmapview-locationtoscreen-returns-nan-nan/m-p/462629#M3963</guid>
      <dc:creator>DiveshGoyal</dc:creator>
      <dc:date>2018-02-13T20:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: AGSMapView.locationToScreen returns (nan,nan)</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/agsmapview-locationtoscreen-returns-nan-nan/m-p/462630#M3964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, I'll try that and report back here. I'll bet that works.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Feb 2018 23:02:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/agsmapview-locationtoscreen-returns-nan-nan/m-p/462630#M3964</guid>
      <dc:creator>WorthSparks</dc:creator>
      <dc:date>2018-02-13T23:02:41Z</dc:date>
    </item>
  </channel>
</rss>

