<?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: How to control the map from a widget? in ArcGIS Experience Builder Questions</title>
    <link>https://community.esri.com/t5/arcgis-experience-builder-questions/how-to-control-the-map-from-a-widget/m-p/1076131#M2340</link>
    <description>&lt;P&gt;I have a widget that needs to interact with two different maps in the application at the same time (a current and future view). The settings (from what I can see) only allow assigning a single map to a widget, so I have handled it as follows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    static mapExtraStateProps(state: IMState) {


        let currentId = "";
        let futureId = "";
        Object.keys(state.appConfig.widgets).forEach(key =&amp;gt; {
            if (state.appConfig.widgets[key].uri === "widgets/arcgis/arcgis-map/" &amp;amp;&amp;amp; state.appConfig.widgets[key].label === "Create") {
                currentId = key;
            }
            if (state.appConfig.widgets[key].uri === "widgets/arcgis/arcgis-map/" &amp;amp;&amp;amp; state.appConfig.widgets[key].label === "Future") {
                futureId = key;
            }
        });

        let currentMap = MapViewManager.getInstance().getJimuMapViewById(currentId + "-dataSource_1");
        let futureMap = MapViewManager.getInstance().getJimuMapViewById(futureId + "-dataSource_1");

        return { currentMap: currentMap, futureMap: futureMap }

    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then the future map and current map are available on the props.&amp;nbsp; I havent bothered to'config out the names of the maps yet. But that would be a future enhancement.&lt;/P&gt;</description>
    <pubDate>Tue, 06 Jul 2021 23:21:29 GMT</pubDate>
    <dc:creator>Grant-S-Carroll</dc:creator>
    <dc:date>2021-07-06T23:21:29Z</dc:date>
    <item>
      <title>How to control the map from a widget?</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/how-to-control-the-map-from-a-widget/m-p/1076068#M2338</link>
      <description>&lt;P&gt;I am trying to create a custom search widget in experience builder and I am getting stuck accessing the map.&lt;BR /&gt;&lt;BR /&gt;I would like to call &lt;STRONG&gt;map.goTo({center: [-199, 33], zoom: 12})&lt;/STRONG&gt; on the map view but I am having some trouble getting access to the &lt;STRONG&gt;JimuMapView&amp;nbsp;&lt;/STRONG&gt;to make this logic work.&lt;BR /&gt;&lt;BR /&gt;Does anyone have any suggestions on how to get access to the map to call this type of logic?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 21:36:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/how-to-control-the-map-from-a-widget/m-p/1076068#M2338</guid>
      <dc:creator>RYANCARL</dc:creator>
      <dc:date>2021-07-06T21:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to control the map from a widget?</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/how-to-control-the-map-from-a-widget/m-p/1076091#M2339</link>
      <description>&lt;P&gt;Looks like I got it.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;We can set the state of the widget with the JMV with the "activeViewChangeHandler"&lt;BR /&gt;&lt;BR /&gt;Something like this:&lt;/P&gt;&lt;PRE&gt;  const [jimuMapView, setJimuMapView] = useState&amp;lt;JimuMapView | null&amp;gt;(null)  &lt;/PRE&gt;&lt;PRE&gt;const testingMapGoTo = () =&amp;gt; {&lt;BR /&gt;      jimuMapView.view.goTo({&lt;BR /&gt;        center: [-119, 33],&lt;BR /&gt;        zoom: 13&lt;BR /&gt;      })&lt;BR /&gt;  }  &lt;/PRE&gt;&lt;PRE&gt;const activeViewChangeHandler = (jmv: JimuMapView) =&amp;gt; {&lt;BR /&gt;    if (jmv) {&lt;BR /&gt;      setJimuMapView(jmv);&lt;BR /&gt;     }&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;I would be super interested if someone has implemented this in any other way&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 22:11:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/how-to-control-the-map-from-a-widget/m-p/1076091#M2339</guid>
      <dc:creator>RYANCARL</dc:creator>
      <dc:date>2021-07-06T22:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to control the map from a widget?</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/how-to-control-the-map-from-a-widget/m-p/1076131#M2340</link>
      <description>&lt;P&gt;I have a widget that needs to interact with two different maps in the application at the same time (a current and future view). The settings (from what I can see) only allow assigning a single map to a widget, so I have handled it as follows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    static mapExtraStateProps(state: IMState) {


        let currentId = "";
        let futureId = "";
        Object.keys(state.appConfig.widgets).forEach(key =&amp;gt; {
            if (state.appConfig.widgets[key].uri === "widgets/arcgis/arcgis-map/" &amp;amp;&amp;amp; state.appConfig.widgets[key].label === "Create") {
                currentId = key;
            }
            if (state.appConfig.widgets[key].uri === "widgets/arcgis/arcgis-map/" &amp;amp;&amp;amp; state.appConfig.widgets[key].label === "Future") {
                futureId = key;
            }
        });

        let currentMap = MapViewManager.getInstance().getJimuMapViewById(currentId + "-dataSource_1");
        let futureMap = MapViewManager.getInstance().getJimuMapViewById(futureId + "-dataSource_1");

        return { currentMap: currentMap, futureMap: futureMap }

    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then the future map and current map are available on the props.&amp;nbsp; I havent bothered to'config out the names of the maps yet. But that would be a future enhancement.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 23:21:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/how-to-control-the-map-from-a-widget/m-p/1076131#M2340</guid>
      <dc:creator>Grant-S-Carroll</dc:creator>
      <dc:date>2021-07-06T23:21:29Z</dc:date>
    </item>
  </channel>
</rss>

