How to reload existing map and view?

06-12-2020 02:50 PM
New Contributor

Hi im currently using the API and react to build a site which houses a map as its primary page.  The map loads fine with all of its layers, however i currently have logic that allows me to "hide" the map div for other elements to show.  I want to be able to reselect my map from the navigation bar I have setup and reload my old map.  

At the moment the map does not display when i try to reshow the div containing the map. 

return ( 



   { this.state.showMap === true && ref={this.mapViewReference }



The data for the old map still exists with all of its layers etc i just want to be able to reload the map.

Tags (2)
0 Kudos
1 Reply
New Contributor

So i was able to come out with a solution however i feel this is a very hacky work around to a feature that arcgis should have by default.

I had to essentially take the object holding my previous map state and copy all of it into a new map with initialization.

const reloadMap (domElementRef) => {

   let oldMap = Object.assign({}, mapObject)

   const map = new Map({

      basemap: oldMap.basemap,




   const view = new MapView({

      container: domElementRef,

      map: map




Code similar to above allows the map to completely reload.  Note:  you will have to readd ui elements again as attempting to directely copy ui elements from the old object does not work.  If anyone has a better solution im open to suggestions

0 Kudos