How to switch or toggle between Web maps in web app builder application?

7251
4
04-15-2015 09:07 AM
NikhilSharma
New Contributor II

Hi All,

I have a web app builder application where I have created a widget to switch web maps in the application. The widget has buttons in it and when I click on the buttons a particular web map is needed to be loaded. Everything is working fine as per needs but the main concern is that the newly loaded web map is ordering itself below the existing web map as a res ult of which the the newly loaded web map cannot be seen. Whenever I try to change the web map using my custom widget it gets added successfully but gets added at the bottom instead of being added at the top due to which one cant see the newly added web map.

What I am really looking for is that when I click on my custom widget the currently shown web map should be hidden and a new web map should be loaded.

Any helps or suggestions would be highly appreciated.

Regards,

Nikhil

0 Kudos
4 Replies
KellyHutchins
Esri Frequent Contributor

There's a sample in the ArcGIS API for JavaScript resource center that shows how to switch maps when clicking a link. In this sample the old map is destroyed and a new one created.

Fade effect using ArcGIS.com web maps | ArcGIS API for JavaScript

NikhilSharma
New Contributor II

Hi Kelly,

Thanks for valuable inputs. I will try implementing the same with my web app builder app and will let you know about the progress.

Thanks,

Nikhil

0 Kudos
NikhilSharma
New Contributor II

Hi Kelly,

I tried to integrate the sample in my web app builder project and was able switch the web maps successfully but this leaded to two more problems.

The sample uses Map.destroy(); method which destroys the map instance and w hen I do that it creates two problems:

1. All the widgets which are a part of map container disappear.

2. The legend and layer list widget are not being updated but show the content for the previously loaded web map instead for the new web map.

Can their be any other approach instead of using Map.destroy(); method as this method creates problems in web app builder application because the other widgets behave as per the previously loaded web map not the newly loaded web map and also the widgets which are part of the map container disappear.

Thanks,

Nikhil

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Nikhil,

  You may want to look at this thread where this exact issue is discussed:

Replace web map in widget code?

0 Kudos