Skip to content

Commit

Permalink
changes in modules loading
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzalezsd committed Jul 5, 2021
1 parent df009b6 commit 99a71a8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 29 deletions.
27 changes: 16 additions & 11 deletions src/components/MapViewer/BasemapWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@ class BasemapWidget extends React.Component {
* @param {*} props
*/
constructor(props) {
return loadModules(['esri/widgets/BasemapGallery']).then(([_BasemapGallery]) => {
super(props);
BasemapGallery = _BasemapGallery;
//We create a reference to a DOM element to be mounted
this.basemaps = createRef();
//Initially, we set the state of the component to
//not be showing the basemap panel
this.state = { showMapMenu: false };
this.menuClass =
'esri-icon-basemap esri-widget--button esri-widget esri-interactive esri-icon-basemap';
});
super(props);
this.loader();
//We create a reference to a DOM element to be mounted
this.basemaps = createRef();
//Initially, we set the state of the component to
//not be showing the basemap panel
this.state = { showMapMenu: false };
this.menuClass =
'esri-icon-basemap esri-widget--button esri-widget esri-interactive esri-icon-basemap';
}

async loader(){
await loadModules(['esri/widgets/BasemapGallery']).then(([_BasemapGallery]) => {
BasemapGallery = _BasemapGallery;
});
}

/**
* Method that will be invoked when the
* button is clicked. It controls the open
Expand Down
36 changes: 18 additions & 18 deletions src/components/MapViewer/MapViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,30 @@ class MapViewer extends React.Component {
*/
constructor(props) {
loadCss();
return loadModules([
this.loader();
super(props);
//we create a reference to the DOM element that will
//be later mounted. We will use the reference that we
//create here to reference the DOM element from javascript
//code, for example, to create later a MapView component
//that will use the map div to show the map
this.mapdiv = createRef();
this.mapCfg = props.cfg.Map;
this.map = null;
this.id = props.id;
this.mapClass = classNames('map-container', {
[`${props.customClass}`]: props.customClass || null,
});
}

async loader() {
await loadModules([
'esri/WebMap',
'esri/views/MapView',
'esri/widgets/Zoom',
]).then(([_Map, _MapView, _Zoom]) => {
[Map,MapView,Zoom] = [_Map, _MapView, _Zoom];
super(props);
//we create a reference to the DOM element that will
//be later mounted. We will use the reference that we
//create here to reference the DOM element from javascript
//code, for example, to create later a MapView component
//that will use the map div to show the map
this.mapdiv = createRef();
this.mapCfg = props.cfg.Map;
this.map = null;
this.id = props.id;
this.mapClass = classNames('map-container', {
[`${props.customClass}`]: props.customClass || null,
});
});


}

/**
Expand All @@ -42,8 +44,6 @@ class MapViewer extends React.Component {
* they are already mounted
*/
componentDidMount() {
loadCss();

// this.mapdiv.current is the reference to the current DOM element of
// this.mapdiv after it was mounted by the render() method
this.map = new Map({
Expand Down

0 comments on commit 99a71a8

Please sign in to comment.