AnsweredAssumed Answered

Is there any OOTB designed utility to change the webmap dynamically in app designed in Web AppBuilder?

Question asked by majetivaraprasad on Apr 20, 2016
Latest reply on Apr 21, 2016 by majetivaraprasad

Hi All,

 

We would like to change the webmap assigned to the app created using Web AppBuilder dynamically in a custom widget. And all other widgets such as "Search",  "Coordinate",  "OverView Map",  "SclareBar",  "HomeButton",  "ZoomSlider" will work with out any impact.  So, could anyone please direct me if there is any OOTB utility available in Web AppBuilder framework?

 

I am following the below procedure to implement this. Please let me know if there is any other best way.

 

1. Destroying current map (by..... this.map.destroy();)

2. Creating a new map with webmap id of desired webmap, using below code

var mapDeferred = jimuUtils.createWebMap("<url of portal>", "newWebmapID",

          mapDivId, {});

3. Publishing "mapChanged" event

      topic.publish('mapChanged', newMapObject);

4. Subscribing this event in all the widgets such as mentioned above and writing necessary code to set map object, events, to the code esri dijits

 

It is working some how. But I am not sure if this is the correct way. So, I would request for any best solutions.

 

Thanks & Regards,

Vara Prasad.

Outcomes