Remove a basemap from Basemap Gallery Widget

03-31-2023 09:24 AM
New Contributor III

I want to add the base map gallery widget to a code and I want to customize the base maps that become available to the user.

In this case I want to remove the ESRI ocean base map from the widget.

Does anybody know how to do this?

Or would I have to manually add the other base maps?

0 Kudos
2 Replies
Regular Contributor

Create your own custom basemap gallery, and add the ones you want. Look at:


0 Kudos
Esri Contributor

You can use the filterFunction on PortalBasemapsSource to filter basemaps in the BasemapGallery. Starting at version 4.27 (planned release in June), you will be able to pass in an asynchronous filter function, allowing you to load the basemap before filtering, like this: 

const basemapGallery = new BasemapGallery({
        view: view,
        source: {
          portal: "",
          // async filterFunction supported starting at v4.27
          filterFunction: async (item, index, basemaps) => {
            let bool = true;
            await item.load().then((loadedBasemap) => {
              // filter out the Oceans basemap
              if (loadedBasemap.title == "Oceans") {
                bool = false;
            return bool;

Here's an example using the development (/next) version of the API:

0 Kudos