Swap web maps in the same view

This sample demonstrates how to initialize multiple WebMaps from Portal for ArcGIS items. You can then swap the active webmap inside a single 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.

1
2
3
4
5
6
7
const webmaps = webmapids.map((webmapid) => {
  return new WebMap({
    portalItem: {
      id: webmapid
    }
  });
});

Then based on an action, such as a button click, you can swap the map by referencing the new web map in the view object.

1
2
const webmap = webmaps[id];
view.map = webmap;

Please refer to the [ArcGIS Organization portals for information on how the makes use of working with portal items.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.

The developer dashboard has moved

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close