import PortalBasemapsSource from "@arcgis/core/widgets/BasemapGallery/support/PortalBasemapsSource.js";const PortalBasemapsSource = await $arcgis.import("@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.
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
basemaps readonly | | |
declaredClass readonly inherited | ||
| | ||
loadError readonly inherited | ||
loadStatus readonly inherited | "not-loaded" | "loading" | "failed" | "loaded" | |
loadWarnings readonly inherited | any[] | |
| | ||
| | ||
state readonly | | |
| |
basemaps
- Type
- Collection<Basemap>
A collection of Basemaps fetched from the source's Portal.
filterFunction
- 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
The Error object returned if an error occurred while loading.
loadStatus
- Type
- "not-loaded" | "loading" | "failed" | "loaded"
Represents the status of a load() operation.
| Value | Description |
|---|---|
| not-loaded | The object's resources have not loaded. |
| loading | The object's resources are currently loading. |
| loaded | The object's resources have loaded without errors. |
| failed | The object's resources failed to load. See loadError for more details. |
- Default value
- "not-loaded"
loadWarnings
- Type
- any[]
A list of warnings which occurred while loading.
query
- 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 objectlet source = new PortalBasemapsSource({ query: { title: "United States Basemaps", owner: "Esri_cy_US" }});// query portal basemaps with a stringlet source = new PortalBasemapsSource({ query: "title:\"United States Basemaps\" AND owner:Esri_cy_US"}); updateBasemapsCallback
- 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
| Method | Signature | Class |
|---|---|---|
cancelLoad inherited | cancelLoad(): this | |
isFulfilled inherited | isFulfilled(): boolean | |
isRejected inherited | isRejected(): boolean | |
isResolved inherited | isResolved(): boolean | |
load inherited | load(options?: AbortOptions | null | undefined): Promise<this> | |
refresh(): Promise<void> | | |
when inherited | when<TResult1 = this, TResult2 = never>(onFulfilled?: OnFulfilledCallback<this, TResult1> | null | undefined, onRejected?: OnRejectedCallback<TResult2> | null | undefined): Promise<TResult1 | TResult2> |
cancelLoad
- Signature
-
cancelLoad (): this
Cancels a load() operation if it is already in progress.
- Returns
- this
isFulfilled
- Signature
-
isFulfilled (): boolean
isFulfilled() may be used to verify if creating an instance of the class is fulfilled (either resolved or rejected).
If it is fulfilled, true will be returned.
- Returns
- boolean
Indicates whether creating an instance of the class has been fulfilled (either resolved or rejected).
isRejected
- Signature
-
isRejected (): boolean
isRejected() may be used to verify if creating an instance of the class is rejected.
If it is rejected, true will be returned.
- Returns
- boolean
Indicates whether creating an instance of the class has been rejected.
isResolved
- Signature
-
isResolved (): boolean
isResolved() may be used to verify if creating an instance of the class is resolved.
If it is resolved, true will be returned.
- Returns
- boolean
Indicates whether creating an instance of the class has been resolved.
load
- Signature
-
load (options?: AbortOptions | null | undefined): Promise<this>
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.
It's possible to provide a signal to stop being interested into a Loadable instance load status.
When the signal is aborted, the instance does not stop its loading process, only cancelLoad() can abort it.
when
- Signature
-
when <TResult1 = this, TResult2 = never>(onFulfilled?: OnFulfilledCallback<this, TResult1> | null | undefined, onRejected?: OnRejectedCallback<TResult2> | null | undefined): Promise<TResult1 | TResult2>
- Since
- ArcGIS Maps SDK for JavaScript 4.6
when() may be leveraged once an instance of the class is created. This method takes two input parameters: an onFulfilled function and an onRejected function.
The onFulfilled executes when the instance of the class loads. The
onRejected executes if the instance of the class fails to load.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| onFulfilled | OnFulfilledCallback<this, TResult1> | null | undefined | 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
onFulfilledthat 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 waylet 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});