Types
import type { BasemapFilter, UpdateBasemapsCallback, BasemapsSourceState } from "@arcgis/core/widgets/BasemapGallery/types.js";

Type definitions

BasemapFilter

Type definition
Since
ArcGIS Maps SDK for JavaScript 5.0

This function is used by the PortalBasemapsSource.filterFunction property to filter basemaps after they are fetched from the Portal.

Support for asynchronous filter functions was added at version 4.27.

Parameters

ParameterTypeDescriptionRequired
item

The current Basemap item being assessed in the array.

index

The index of the Basemap being assessed.

array

The array of basemaps being filtered.

Returns
boolean | Promise<boolean>

Returns true if the test passes, false otherwise.

UpdateBasemapsCallback

Type definition
Since
ArcGIS Maps SDK for JavaScript 5.0

This function is used by the PortalBasemapsSource.updateBasemapsCallback property for updating basemaps after being fetched and filtered.

Support for asynchronous update functions was added at version 4.29.

Parameters

ParameterTypeDescriptionRequired
items

An array of basemaps that have been fetched and filtered from the Portal.

Returns
Basemap[] | Promise<Basemap[]>

The array of basemaps to display in the BasemapGallery widget.

Examples
// Create custom basemap to be added to the array of portal basemaps
const basemapGallery = new BasemapGallery({
view: view,
source: {
query: {
title: "United States Basemaps",
owner: "Esri_cy_US"
},
updateBasemapsCallback: (items) => {
// create custom basemap to be added to the array of portal basemaps
let bm = new Basemap({
portalItem: {
id: "8dda0e7b5e2d4fafa80132d59122268c" // WGS84 Streets Vector webmap
}
});
// add basemap to the array
items.push(bm);
// return the array of basemaps
return items;
}
}
});
// Add current basemap if not already present
const currentBasemap = map.basemap;
const basemapGallery = new BasemapGallery({
view,
source: {
portal: "https://arcgis.com",
async updateBasemapsCallback(items) {
for (const item of items) {
// load basemap for proper comparison
await item.load();
if (basemapGallery.viewModel.basemapEquals(currentBasemap, item))
return items;
}
// add the current basemap if not found in the array of basemap items
return [currentBasemap, ...items];
}
}
});

BasemapsSourceState

Type definition
Since
ArcGIS Maps SDK for JavaScript 5.0
Type
"ready" | "loading" | "not-loaded"