<?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: Cannot read property 'toScreen' of undefined in ArcGIS Web AppBuilder Questions</title>
    <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/cannot-read-property-toscreen-of-undefined/m-p/639455#M17013</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When I used this.map.infowindow.show() I get this error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"TypeError: Cannot read property 'toScreen' of undefined&lt;SPAN style="line-height: 1.5;"&gt;&lt;SPAN&gt; at p.show (&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fjs.arcgis.com%2F3.14%2Finit.js%3A1639%3A501" rel="nofollow" target="_blank"&gt;http://js.arcgis.com/3.14/init.js:1639:501&lt;/A&gt;&lt;SPAN&gt;)..."&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Oct 2015 22:25:50 GMT</pubDate>
    <dc:creator>AndrewTerwiel</dc:creator>
    <dc:date>2015-10-07T22:25:50Z</dc:date>
    <item>
      <title>Cannot read property 'toScreen' of undefined</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/cannot-read-property-toscreen-of-undefined/m-p/639449#M17007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have this simple chunk of code that fails with the error:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"TypeError: Cannot read property 'toScreen' of undefined at p.show (&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fjs.arcgis.com%2F3.14%2Finit.js%3A199" target="_blank"&gt;http://js.arcgis.com/3.14/init.js:199&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It fails at &lt;SPAN style="color: blue;"&gt;this&lt;/SPAN&gt;.map.infoWindow.show(selectedAddress[0].geometry, selectedAddress[0].geometry);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: blue;"&gt;var&lt;/SPAN&gt; infoTemplate = &lt;SPAN style="color: blue;"&gt;new&lt;/SPAN&gt; InfoTemplate();
infoTemplate.title = &lt;SPAN style="color: #a31515;"&gt;"Address"&lt;/SPAN&gt;;
infoTemplate.content = &lt;SPAN style="color: #a31515;"&gt;"${ADDRESS}&amp;lt;/br&amp;gt;${LOCALITY}"&lt;/SPAN&gt;;
selectedAddress[0].setInfoTemplate(infoTemplate);
&lt;SPAN style="color: blue;"&gt;this&lt;/SPAN&gt;.map.infoWindow.setFeatures(selectedAddress);
&lt;SPAN style="color: blue;"&gt;this&lt;/SPAN&gt;.map.infoWindow.show(selectedAddress[0].geometry, selectedAddress[0].geometry);&lt;/PRE&gt;&lt;P&gt;Can anyone see what I'm doing wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Andrew Terwiel&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have it working now, but this looks like a hack to me.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: blue;"&gt;var&lt;/SPAN&gt; that = &lt;SPAN style="color: blue;"&gt;this&lt;/SPAN&gt;.map._mapParams.infoWindow;
&lt;SPAN style="color: blue;"&gt;var&lt;/SPAN&gt; infoTemplate = &lt;SPAN style="color: blue;"&gt;new&lt;/SPAN&gt; InfoTemplate();
infoTemplate.title = &lt;SPAN style="color: #a31515;"&gt;"Address"&lt;/SPAN&gt;;
infoTemplate.content = &lt;SPAN style="color: #a31515;"&gt;"${ADDRESS}&amp;lt;/br&amp;gt;${LOCALITY}"&lt;/SPAN&gt;;
selected[0].setInfoTemplate(infoTemplate);
that.setFeatures(selected);
that.show(selected[0].geometry);&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:10:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/cannot-read-property-toscreen-of-undefined/m-p/639449#M17007</guid>
      <dc:creator>AndrewTerwiel</dc:creator>
      <dc:date>2021-12-12T03:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot read property 'toScreen' of undefined</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/cannot-read-property-toscreen-of-undefined/m-p/639450#M17008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The documentation for &lt;A href="https://developers.arcgis.com/javascript/jsapi/infowindow-amd.html#show" title="https://developers.arcgis.com/javascript/jsapi/infowindow-amd.html#show" rel="nofollow noopener noreferrer" target="_blank"&gt;InfoWindow&lt;/A&gt; states that the location:&lt;SPAN style="background-color: #fafafa;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;SPAN style="background-color: #fafafa;"&gt;is an instance of &lt;/SPAN&gt;&lt;CODE&gt;esri.geometry.Point&lt;/CODE&gt;&lt;SPAN style="background-color: #fafafa;"&gt;. If the location has a spatial reference, it is assumed to be in map coordinates otherwise screen coordinates are used. &lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I would suggest using &lt;A href="https://developers.arcgis.com/javascript/jsapi/map-amd.html#toscreen" rel="nofollow noopener noreferrer" target="_blank"&gt;map.toScreen()&lt;/A&gt; to convert your geometry to a screen coordinate. Your last line of code would change to something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var screenPt = this.map.toScreen(selectedAddress[0].geometry);
this.map.infoWindow.show(screenPt, this.map.getInfoWindowAnchor(screenPt));&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See this example - &lt;A href="https://developers.arcgis.com/javascript/jssamples/query_charts.html" rel="nofollow noopener noreferrer" target="_blank"&gt;https://developers.arcgis.com/javascript/jssamples/query_charts.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:10:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/cannot-read-property-toscreen-of-undefined/m-p/639450#M17008</guid>
      <dc:creator>OwenEarley</dc:creator>
      <dc:date>2021-12-12T03:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot read property 'toScreen' of undefined</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/cannot-read-property-toscreen-of-undefined/m-p/639451#M17009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Owen. See my edit for the fix.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Oct 2015 01:43:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/cannot-read-property-toscreen-of-undefined/m-p/639451#M17009</guid>
      <dc:creator>AndrewTerwiel</dc:creator>
      <dc:date>2015-10-07T01:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot read property 'toScreen' of undefined</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/cannot-read-property-toscreen-of-undefined/m-p/639452#M17010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Andrew,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Is there a reason you are using InfoTemplate instead of PopupTemplate? The maps default infoWindow is a Poppp dijit and would normally be expecting a PopupTemplate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this.map.infoWindow.show(point); The show method can take a standard esri point geometry and does not require it to be in screen coordinates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var popupTemplate = new PopupTemplate();
popupTemplate.title = "Address";
popupTemplate.content = "${ADDRESS}&amp;lt;/br&amp;gt;${LOCALITY}";
selectedAddress[0].setInfoTemplate(popupTemplate);
this.map.infoWindow.setFeatures(selectedAddress);
this.map.infoWindow.show(selectedAddress[0].geometry);&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:10:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/cannot-read-property-toscreen-of-undefined/m-p/639452#M17010</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-12T03:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot read property 'toScreen' of undefined</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/cannot-read-property-toscreen-of-undefined/m-p/639453#M17011</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robert, I was using InfoTemplate out of ignorance. However, now that I'm using PopupTemplate the title is not displaying. When I use the developer tools, I see that the title has been applied to the template, but I can't see why it doesn't show in the popup. By the way, how do I get my code snippets to look nice like I see in other posts?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: blue;"&gt;var&lt;/SPAN&gt; that = &lt;SPAN style="color: blue;"&gt;this&lt;/SPAN&gt;.map._mapParams.infoWindow;
&lt;SPAN style="color: blue;"&gt;var&lt;/SPAN&gt; popupTemplate = &lt;SPAN style="color: blue;"&gt;new&lt;/SPAN&gt; PopupTemplate();
popupTemplate.title = &lt;SPAN style="color: #a31515;"&gt;"Address"&lt;/SPAN&gt;;
popupTemplate.content = &lt;SPAN style="color: #a31515;"&gt;"${ADDRESS}&amp;lt;/br&amp;gt;${LOCALITY}"&lt;/SPAN&gt;;
selected[0].setInfoTemplate(popupTemplate);
that.setFeatures(selected);
that.show(selected[0].geometry);&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:10:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/cannot-read-property-toscreen-of-undefined/m-p/639453#M17011</guid>
      <dc:creator>AndrewTerwiel</dc:creator>
      <dc:date>2021-12-12T03:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot read property 'toScreen' of undefined</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/cannot-read-property-toscreen-of-undefined/m-p/639454#M17012</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Andrew,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Not sure why you are using:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var that = this.map._mapParams.infoWindow;&lt;/PRE&gt;&lt;P&gt;you should always avoid using underscore functions or properties.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Something like this should work fine:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var popupTemplate = new PopupTemplate();
popupTemplate.setTitle = "Address";
popupTemplate.setContent = "${ADDRESS}&amp;lt;/br&amp;gt;${LOCALITY}";
selected[0].setInfoTemplate(popupTemplate);
this.map.infoWindow.setFeatures(selected);
this.map.infoWindow.show(selected[0].geometry);&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For code formatting see this link:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/message/390814" target="_blank"&gt;Re: How to format a code sample on GeoNet?&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:10:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/cannot-read-property-toscreen-of-undefined/m-p/639454#M17012</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-12T03:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot read property 'toScreen' of undefined</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/cannot-read-property-toscreen-of-undefined/m-p/639455#M17013</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When I used this.map.infowindow.show() I get this error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"TypeError: Cannot read property 'toScreen' of undefined&lt;SPAN style="line-height: 1.5;"&gt;&lt;SPAN&gt; at p.show (&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fjs.arcgis.com%2F3.14%2Finit.js%3A1639%3A501" rel="nofollow" target="_blank"&gt;http://js.arcgis.com/3.14/init.js:1639:501&lt;/A&gt;&lt;SPAN&gt;)..."&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Oct 2015 22:25:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/cannot-read-property-toscreen-of-undefined/m-p/639455#M17013</guid>
      <dc:creator>AndrewTerwiel</dc:creator>
      <dc:date>2015-10-07T22:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot read property 'toScreen' of undefined</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/cannot-read-property-toscreen-of-undefined/m-p/639456#M17014</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Andrew,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Strange. I use this.map.infoWindow all the time in my widgets.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Oct 2015 01:29:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/cannot-read-property-toscreen-of-undefined/m-p/639456#M17014</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-10-08T01:29:22Z</dc:date>
    </item>
  </channel>
</rss>

