<?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 access jimuMapView from another component in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/access-jimumapview-from-another-component/m-p/1233403#M79389</link>
    <description>&lt;P&gt;Newbie with React.&lt;/P&gt;&lt;P&gt;I have a long code so I split it to different components.&lt;/P&gt;&lt;P&gt;I have the main widget.tsx component and I imported another component PMtoXY to it.&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;import PMtoXY from "./PMtoXY";&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the widget, I defined the jimuMapView to access the selected map (script below).&lt;/P&gt;&lt;P&gt;In the PMtoXY, I defined a feature layer and want to add it to the map. How do I access the current state of the&amp;nbsp; jimuMapView in the PMtoXY?&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;import {
JimuMapViewComponent,
  JimuMapView,
} from "jimu-arcgis";
=====
interface IState {
  jimuMapView: JimuMapView;
----
----
state = {
    jimuMapView: null,
-----
----
activeViewChangeHandler = (jmv: JimuMapView) =&amp;gt; {
    if (jmv) {
      this.setState({ jimuMapView: jmv });
    }
  };
------
-----
 render() {
    return (
      &amp;lt;div className="widget-addLayers jimu-widget p-2"&amp;gt;
        {this.props.hasOwnProperty("useMapWidgetIds") &amp;amp;&amp;amp;
          this.props.useMapWidgetIds &amp;amp;&amp;amp;
          this.props.useMapWidgetIds[0] &amp;amp;&amp;amp; (
            &amp;lt;JimuMapViewComponent
              useMapWidgetId={this.props.useMapWidgetIds?.[0]}
              onActiveViewChange={this.activeViewChangeHandler}              
            /&amp;gt;
          )}
--------
--------&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 18 Nov 2022 21:01:19 GMT</pubDate>
    <dc:creator>LefterisKoumis</dc:creator>
    <dc:date>2022-11-18T21:01:19Z</dc:date>
    <item>
      <title>access jimuMapView from another component</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/access-jimumapview-from-another-component/m-p/1233403#M79389</link>
      <description>&lt;P&gt;Newbie with React.&lt;/P&gt;&lt;P&gt;I have a long code so I split it to different components.&lt;/P&gt;&lt;P&gt;I have the main widget.tsx component and I imported another component PMtoXY to it.&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;import PMtoXY from "./PMtoXY";&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the widget, I defined the jimuMapView to access the selected map (script below).&lt;/P&gt;&lt;P&gt;In the PMtoXY, I defined a feature layer and want to add it to the map. How do I access the current state of the&amp;nbsp; jimuMapView in the PMtoXY?&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;import {
JimuMapViewComponent,
  JimuMapView,
} from "jimu-arcgis";
=====
interface IState {
  jimuMapView: JimuMapView;
----
----
state = {
    jimuMapView: null,
-----
----
activeViewChangeHandler = (jmv: JimuMapView) =&amp;gt; {
    if (jmv) {
      this.setState({ jimuMapView: jmv });
    }
  };
------
-----
 render() {
    return (
      &amp;lt;div className="widget-addLayers jimu-widget p-2"&amp;gt;
        {this.props.hasOwnProperty("useMapWidgetIds") &amp;amp;&amp;amp;
          this.props.useMapWidgetIds &amp;amp;&amp;amp;
          this.props.useMapWidgetIds[0] &amp;amp;&amp;amp; (
            &amp;lt;JimuMapViewComponent
              useMapWidgetId={this.props.useMapWidgetIds?.[0]}
              onActiveViewChange={this.activeViewChangeHandler}              
            /&amp;gt;
          )}
--------
--------&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2022 21:01:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/access-jimumapview-from-another-component/m-p/1233403#M79389</guid>
      <dc:creator>LefterisKoumis</dc:creator>
      <dc:date>2022-11-18T21:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: access jimuMapView from another component</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/access-jimumapview-from-another-component/m-p/1233433#M79390</link>
      <description>&lt;P&gt;I am not familiar with ExB or using the jimu framework, but it looks like you can create connections between widgets.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/experience-builder/guide/add-widgets/#connect-widgets" target="_blank"&gt;https://developers.arcgis.com/experience-builder/guide/add-widgets/#connect-widgets&lt;/A&gt;&lt;/P&gt;&lt;P&gt;There a number of actions that you can use to communicate, but I'm not sure what the best pattern would be for your use case.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/experience-builder/guide/action-triggers/" target="_blank"&gt;https://developers.arcgis.com/experience-builder/guide/action-triggers/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2022 21:58:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/access-jimumapview-from-another-component/m-p/1233433#M79390</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2022-11-18T21:58:34Z</dc:date>
    </item>
  </channel>
</rss>

