WAB swap webmap

832
1
11-22-2019 12:02 PM
NicolasRoger
Occasional Contributor

Hello,

is it possible to swap the webmap used in my WAB app for a new map at the click of a button?

The original webmap is set in the config of the app. I am trying to swap the webmap for a new one like so (following this sample code Web map by ID | ArcGIS API for JavaScript 3.30 😞

arcgisUtils.createMap("ckdklsdjksd98sdjxxxXX89", "map").then((response) => {
            this.map = response.map;
        });‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

That doesn't seems to do anything. So I tried destroying the old map before adding the new one like so:

arcgisUtils.createMap("ckdklsdjksd98sdjxxxXX89", "map").then((response) => {
            this.map.destroy();
            this.map = response.map;
        });‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

It kinda work but then all my widgets are gone!

What am I missing?

0 Kudos
1 Reply
NicolasRoger
Occasional Contributor

I just tried with "removeAllLayers()":

arcgisUtils.createMap("ckdklsdjksd98sdjxxxXX89", "map").then((response) => {
            this.map.removeAllLayers();‍‍
            this.map = response.map;
        });‍‍‍‍‍

Doesn't work either.

0 Kudos