Swap web maps in the same app

Note: Support for 3D on mobile devices may vary, view the system requirements for more information.

This sample demonstrates how to initialize multiple WebMaps from ArcGIS for Portal items. You can then swap the active webmap inside a new view.

This sample uses the following web maps:

  • Missing Migrants - shows all of the missing migrant reports from the International Organization for Migration (IOM). The bright blue symbols represent reports submitted in 2015 or later while the dark blue symbolizes incidents before 2015. The larger symbols represent greater number of reported deaths.
  • Refugee Routes - shows refugee routes into Europe.
  • 2015 European Sea Arrivals - shows arrivals in southern Europe of refugees by sea, January through July 2015.

First, create an array of WebMaps without loading them.

var webmaps = webmapids.map(function(webmapid) {
  return new WebMap({
    portalItem: {
      id: webmapid
    }
  });
});

Then based on an action, such as a button click, you can swap the map displayed in the app by creating a new view and referencing the new webmap.

function createView(webmap) {
  var view = new MapView({
    map: webmap,
    container: "viewDiv"
  });
}

// Get an index for the "WebMap" array
var webmap = webmaps[id];
createView(webmap);

Sample search results

TitleSample

There were no match results from your search criteria.