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
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
| Parameter | Type | Description | Required |
|---|---|---|---|
| items | Basemap[] | An array of basemaps that have been fetched and filtered from the Portal. | |
- Examples
- // Create custom basemap to be added to the array of portal basemapsconst 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 basemapslet bm = new Basemap({portalItem: {id: "8dda0e7b5e2d4fafa80132d59122268c" // WGS84 Streets Vector webmap}});// add basemap to the arrayitems.push(bm);// return the array of basemapsreturn items;}}});// Add current basemap if not already presentconst 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 comparisonawait item.load();if (basemapGallery.viewModel.basemapEquals(currentBasemap, item))return items;}// add the current basemap if not found in the array of basemap itemsreturn [currentBasemap, ...items];}}});