import PortalBasemapsSource from "@arcgis/core/widgets/BasemapGallery/support/PortalBasemapsSource.js";
Inheritance
PortalBasemapsSource→LocalBasemapsSource→Accessor
Since
ArcGIS Maps SDK for JavaScript 4.3

The PortalBasemapsSource class is a Portal-driven Basemap BasemapGalleryViewModel.source in the BasemapGalleryViewModel or BasemapGallery widget.

See also

Constructors

Constructor

Constructor

Parameters

ParameterTypeDescriptionRequired
properties
See the properties table for a list of all the properties that may be passed into the constructor.

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.
PropertyTypeClass
readonly
readonly inherited
readonly inherited
readonly inherited
"not-loaded" | "loading" | "failed" | "loaded"
readonly inherited
any[]
readonly

basemaps

readonly Property
Type
Collection<Basemap>

A collection of Basemaps fetched from the source's Portal.

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor
Since
ArcGIS Maps SDK for JavaScript 4.7

The name of the class. The declared class name is formatted as esri.folder.className.

filterFunction

Property
Type
BasemapFilter | null | undefined

Function used to filter basemaps after being fetched from the Portal.

Example
const basemapGallery = new BasemapGallery({
view: view,
source: {
portal: "https://arcgis.com",
// async filterFunction support added 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;
}
}
});

loadError

readonlyinherited Property
Type
EsriError | null | undefined
Inherited from: LoadableMixin

The Error object returned if an error occurred while loading.

loadStatus

readonlyinherited Property
Type
"not-loaded" | "loading" | "failed" | "loaded"
Inherited from: LoadableMixin

Represents the status of a load() operation.

ValueDescription
not-loadedThe object's resources have not loaded.
loadingThe object's resources are currently loading.
loadedThe object's resources have loaded without errors.
failedThe object's resources failed to load. See loadError for more details.
Default value
"not-loaded"

loadWarnings

readonlyinherited Property
Type
any[]
Inherited from: LoadableMixin

A list of warnings which occurred while loading.

portal

autocast Property
Type
Portal

The Portal from which to fetch basemaps.

query

Property
Type
Record<string, any> | string | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.5

An object with key-value pairs used to create a custom basemap gallery group query. Note that all parameters will be joined using the AND operator. A query string can also be provided for more advanced use cases.

Examples
// query portal basemaps with an object
let source = new PortalBasemapsSource({
query: {
title: "United States Basemaps",
owner: "Esri_cy_US"
}
});
// query portal basemaps with a string
let source = new PortalBasemapsSource({
query: "title:\"United States Basemaps\" AND owner:Esri_cy_US"
});

state

readonly Property
Type
BasemapsSourceState

The source's state.

Default value
"not-loaded"

updateBasemapsCallback

Property
Type
UpdateBasemapsCallback | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.8

Callback for updating basemaps after being fetched and filtered. This can be useful if you want to add a custom basemap after fetching the portal basemaps.

Methods

MethodSignatureClass
inherited
cancelLoad(): this
inherited
isFulfilled(): boolean
inherited
isRejected(): boolean
inherited
isResolved(): boolean
inherited
load(options?: AbortOptions | null | undefined): Promise<this>
refresh(): Promise<void>
inherited
when<TResult1 = this, TResult2 = never>(onFulfilled?: OnFulfilledCallback<this, TResult1> | null | undefined, onRejected?: OnRejectedCallback<TResult2> | null | undefined): Promise<TResult1 | TResult2>

cancelLoad

inherited Method
Signature
cancelLoad (): this
Inherited from: LoadableMixin

Cancels a load() operation if it is already in progress.

Returns
this

isFulfilled

inherited Method
Signature
isFulfilled (): boolean
Inherited from: EsriPromiseMixin

isFulfilled() may be used to verify whether the promise has been fulfilled (either resolved or rejected).

Returns
boolean

Whether the promise has been fulfilled (either resolved or rejected).

isRejected

inherited Method
Signature
isRejected (): boolean
Inherited from: EsriPromiseMixin

isRejected() may be used to verify whether the promise has been rejected.

Returns
boolean

Whether the promise has been rejected.

isResolved

inherited Method
Signature
isResolved (): boolean
Inherited from: EsriPromiseMixin

isResolved() may be used to verify whether the promise has resolved.

Returns
boolean

Whether the promise has resolved.

load

inherited Method
Signature
load (options?: AbortOptions | null | undefined): Promise<this>
Inherited from: LoadableMixin

Loads the resources referenced by this class. This method automatically executes for a View and all of the resources it references in Map if the view is constructed with a map instance.

This method must be called by the developer when accessing a resource that will not be loaded in a View.

The load() method only triggers the loading of the resource the first time it is called. The subsequent calls return the same promise.

A signal can be provided to stop waiting for a Loadable instance to load. When the signal is aborted, the instance does not stop its loading process, only cancelLoad() can abort it.

Parameters

ParameterTypeDescriptionRequired
options

Additional options.

Returns
Promise<this>

Resolves when the resources have loaded.

refresh

Method
Signature
refresh (): Promise<void>

Refreshes basemaps by fetching them from the Portal.

Returns
Promise<void>

A promise that resolves when the basemaps have been fetched.

when

inherited Method
Signature
when <TResult1 = this, TResult2 = never>(onFulfilled?: OnFulfilledCallback<this, TResult1> | null | undefined, onRejected?: OnRejectedCallback<TResult2> | null | undefined): Promise<TResult1 | TResult2>
Type parameters
<TResult1 = this, TResult2 = never>
Inherited from: EsriPromiseMixin
Since
ArcGIS Maps SDK for JavaScript 4.6

when() may be used with an instance of this class. This method takes two input parameters: an onFulfilled function and an onRejected function. The onFulfilled function executes when the promise resolves. The onRejected function executes if the promise is rejected.

Parameters

ParameterTypeDescriptionRequired
onFulfilled

The function to call when the promise resolves.

onRejected

The function to execute when the promise fails.

Returns
Promise<TResult1 | TResult2>

Returns a new promise for the result of onFulfilled that may be used to chain additional functions.

Example
// Although this example uses MapView, any class instance that is a promise may use when() in the same way
let view = new MapView();
view.when(function(){
// This function will execute once the promise is resolved
}, function(error){
// This function will execute if the promise is rejected due to an error
});