<?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 Promises before function is ran in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/promises-before-function-is-ran/m-p/1074522#M73713</link>
    <description>&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;I have a function in my web appbuilder developer app. I want the function to not run until the promise is returned that the top layer in my agol web map has resolved if the map is re-centered and the layer has to refresh first. I think the top layer in agol maps is identified as the highest [number] and bottom layer which is the basemap is [0] when using the api.&amp;nbsp; How do I set this promise?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Promise snippet I found and would like intergrated into the existing code:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="pln"&gt; promises &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; all&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;([&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;parcels&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; buildings&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;]);&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; promises&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;then&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;handleQueryResults&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Existing code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;setTimeout(lang.hitch(this, function(){
          var mpPt;
          if(result.feature.geometry.type === "point"){mpPt = result.feature.geometry;}

          //else{mpPt = result.feature.geometry.getExtent().getCenter();}
          var scrPt = this.map.toScreen(mpPt);
          this.map.emit("click", { 
            bubbles: true, 
            cancelable: true, 
            mapPoint: mpPt,
            screenPoint: scrPt
          });
        }),1400);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Jun 2021 23:40:57 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-06-30T23:40:57Z</dc:date>
    <item>
      <title>Promises before function is ran</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/promises-before-function-is-ran/m-p/1074522#M73713</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;I have a function in my web appbuilder developer app. I want the function to not run until the promise is returned that the top layer in my agol web map has resolved if the map is re-centered and the layer has to refresh first. I think the top layer in agol maps is identified as the highest [number] and bottom layer which is the basemap is [0] when using the api.&amp;nbsp; How do I set this promise?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Promise snippet I found and would like intergrated into the existing code:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="pln"&gt; promises &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; all&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;([&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;parcels&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; buildings&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;]);&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; promises&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;then&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;handleQueryResults&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Existing code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;setTimeout(lang.hitch(this, function(){
          var mpPt;
          if(result.feature.geometry.type === "point"){mpPt = result.feature.geometry;}

          //else{mpPt = result.feature.geometry.getExtent().getCenter();}
          var scrPt = this.map.toScreen(mpPt);
          this.map.emit("click", { 
            bubbles: true, 
            cancelable: true, 
            mapPoint: mpPt,
            screenPoint: scrPt
          });
        }),1400);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 23:40:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/promises-before-function-is-ran/m-p/1074522#M73713</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-06-30T23:40:57Z</dc:date>
    </item>
  </channel>
</rss>

