Newbie with React.
I have a long code so I split it to different components.
I have the main widget.tsx component and I imported another component PMtoXY to it.
import PMtoXY from "./PMtoXY";
In the widget, I defined the jimuMapView to access the selected map (script below).
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 jimuMapView in the PMtoXY?
import {
JimuMapViewComponent,
JimuMapView,
} from "jimu-arcgis";
=====
interface IState {
jimuMapView: JimuMapView;
----
----
state = {
jimuMapView: null,
-----
----
activeViewChangeHandler = (jmv: JimuMapView) => {
if (jmv) {
this.setState({ jimuMapView: jmv });
}
};
------
-----
render() {
return (
<div className="widget-addLayers jimu-widget p-2">
{this.props.hasOwnProperty("useMapWidgetIds") &&
this.props.useMapWidgetIds &&
this.props.useMapWidgetIds[0] && (
<JimuMapViewComponent
useMapWidgetId={this.props.useMapWidgetIds?.[0]}
onActiveViewChange={this.activeViewChangeHandler}
/>
)}
--------
--------
I am not familiar with ExB or using the jimu framework, but it looks like you can create connections between widgets.
https://developers.arcgis.com/experience-builder/guide/add-widgets/#connect-widgets
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.
https://developers.arcgis.com/experience-builder/guide/action-triggers/