<?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: ExpB code: runs in one location but not the other.....Why in ArcGIS Experience Builder Questions</title>
    <link>https://community.esri.com/t5/arcgis-experience-builder-questions/expb-code-runs-in-one-location-but-not-the-other/m-p/1413472#M12214</link>
    <description>&lt;P&gt;My first thought when looking at these two clips was the following.&lt;BR /&gt;&lt;BR /&gt;I'm presuming that mapView exists and isActive returns a boolean and not null, is it possible mv1Ext doesn't exist when it is called?&lt;BR /&gt;&lt;BR /&gt;The only other thought that I can think of, is that this is an issue where there won't be a rerender because the props being used in that function have not changed.&amp;nbsp; It may be you need something to signal that it should force re-render.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 22 Apr 2024 12:39:40 GMT</pubDate>
    <dc:creator>TimWestern</dc:creator>
    <dc:date>2024-04-22T12:39:40Z</dc:date>
    <item>
      <title>ExpB code: runs in one location but not the other.....Why</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/expb-code-runs-in-one-location-but-not-the-other/m-p/1412477#M12201</link>
      <description>&lt;P&gt;Below are pretty much 2 identical sets of code.&lt;/P&gt;&lt;P&gt;One set of code is called by a JimuMapviewComponent activeViewChangeHandler. Sets current JMV to correct Extent but does not reset the Home Button to needed extent.&amp;nbsp; does not error. just does not do it.&lt;/P&gt;&lt;P&gt;The other code is called by a DataSourceComponent Render.&amp;nbsp; This code sets current JMV to correct Extent AND sets&amp;nbsp; the Home Button to needed extent.&lt;/P&gt;&lt;P&gt;See below:&lt;/P&gt;&lt;P&gt;When the map is switched this code fires.&amp;nbsp; The map zooms to the previous saved extent(mv1Ext).&amp;nbsp; Then the JimuMaptool (jsapi Home widget) is found.&amp;nbsp; But the Home widget will not take the new home extent of mv1Ext (which was just used above).&amp;nbsp; &amp;nbsp;The Home extent defaults to all features in layer.&lt;/P&gt;&lt;PRE&gt; const activeViewChangeHandler = (jmv: JimuMapView) =&amp;gt; {
    if (jmv) {
      alert(jmv.dataSourceId)
      if (mapView.isActive) {
        alert('mapView.isActive') 
        if (mv1Ext) {
          jmv.view.goTo(mv1Ext)
          let myViewpoint = new Viewpoint ({targetGeometry: mv1Ext})
          const MapTools:JimuMapTool[] = jmv.jimuMapTools
          MapTools.forEach( (element) =&amp;gt; {
            if (element.name === "Home") {
              alert('found Home Widget')
              element.instance.viewpoint = new Viewpoint({targetGeometry: mv1Ext})
            }
          })
        }       
      }
    }
  }&lt;/PRE&gt;&lt;P&gt;The above code is used in the jmv component render event&lt;/P&gt;&lt;P&gt;See successfully executing code below:&amp;nbsp; This is called by a DataSourceComponent Render.&lt;/P&gt;&lt;PRE&gt;    else if (myTitle.includes("Hot")) {
      if (!mapView.isActive) {return}
      mySQL = HZquery.where
      if (myTitle.includes("Hot")) {     
        DL_layer.definitionExpression = mySQL
          DL_layer.when(() =&amp;gt; {
            return DL_layer.queryExtent()
          })
          .then((response) =&amp;gt; {
            myExt = response.extent
            myExt.expand(1.25)
            mv1Ext = myExt
            mapView.view.goTo(myExt)
            const MapTools:JimuMapTool[] = mapView.jimuMapTools
            MapTools.forEach( (element) =&amp;gt; {
              if (element.name === "Home") {
                element.instance.viewpoint = new Viewpoint({targetGeometry: mv1Ext})
              }
            })
          })
        }   
    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Note the same code getting the jsapi Home widget.&amp;nbsp; This code executes fine and sets the Home extent to the previously set mv1Ext.&lt;/P&gt;&lt;P&gt;Any ideas what is going on?&lt;/P&gt;&lt;P&gt;BobinTN&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2024 19:01:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/expb-code-runs-in-one-location-but-not-the-other/m-p/1412477#M12201</guid>
      <dc:creator>brundageb</dc:creator>
      <dc:date>2024-04-19T19:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: ExpB code: runs in one location but not the other.....Why</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/expb-code-runs-in-one-location-but-not-the-other/m-p/1413472#M12214</link>
      <description>&lt;P&gt;My first thought when looking at these two clips was the following.&lt;BR /&gt;&lt;BR /&gt;I'm presuming that mapView exists and isActive returns a boolean and not null, is it possible mv1Ext doesn't exist when it is called?&lt;BR /&gt;&lt;BR /&gt;The only other thought that I can think of, is that this is an issue where there won't be a rerender because the props being used in that function have not changed.&amp;nbsp; It may be you need something to signal that it should force re-render.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 12:39:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/expb-code-runs-in-one-location-but-not-the-other/m-p/1413472#M12214</guid>
      <dc:creator>TimWestern</dc:creator>
      <dc:date>2024-04-22T12:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: ExpB code: runs in one location but not the other.....Why</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/expb-code-runs-in-one-location-but-not-the-other/m-p/1413655#M12222</link>
      <description>&lt;P&gt;Hey Tim,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much for responding.&amp;nbsp; MapView.isActive does return a Boolean.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In both sets of code mv1Ext is present with value because the Active MapView Does get set to this mv1Ext (the map zooms to this mv1Ext).&lt;/P&gt;&lt;P&gt;But on the activeViewChangeHandler execution the code (sets and zooms to mv1Ext) but does not set the mv1Ext to the Home button (JimuMapTool).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 18:22:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/expb-code-runs-in-one-location-but-not-the-other/m-p/1413655#M12222</guid>
      <dc:creator>brundageb</dc:creator>
      <dc:date>2024-04-22T18:22:27Z</dc:date>
    </item>
  </channel>
</rss>

