▾
import BasemapGalleryViewModel from "@arcgis/core/widgets/BasemapGallery/BasemapGalleryViewModel.js";const BasemapGalleryViewModel = await $arcgis.import("@arcgis/core/widgets/BasemapGallery/BasemapGalleryViewModel.js");- Inheritance
- BasemapGalleryViewModel→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 4.3
Provides the logic for the BasemapGallery widget and component.
- See also
BasemapGallery widget - Deprecated since 4.32. Use the Basemap Gallery component instead.
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
| | ||
| readonly | | |
| readonly inherited | ||
| readonly | | |
| readonly inherited | ||
| readonly inherited | "not-loaded" | "loading" | "failed" | "loaded" | |
| readonly inherited | any[] | |
| | ||
| readonly | | |
| |
activeBasemapIndex
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 4.32
The current index of the active Map.basemap in the BasemapGallery.
items
- Type
- Collection<BasemapGalleryItem>
A collection of BasemapGalleryItems representing basemaps.
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.
source
The source for basemaps that the Basemap Gallery will display. This property can be autocast with an array or Collection of Basemaps, or a Portal instance. The default source is a PortalBasemapsSource that points to the default portal instance set in esriConfig.portalUrl.
view
- Type
- MapViewOrSceneView | null | undefined
The view from which the Basemap Gallery will operate. This view provides access to the active Map.basemap via the view's View.map property.
Methods
| Method | Signature | Class |
|---|---|---|
| basemapEquals(basemap1: Basemap | null | undefined, basemap2: Basemap | null | undefined): boolean | | |
| inherited | cancelLoad(): this | |
| inherited | isFulfilled(): boolean | |
| inherited | isRejected(): boolean | |
| inherited | isResolved(): boolean | |
| inherited | load(options?: AbortOptions | null | undefined): Promise<this> | |
| 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 whether the promise has been fulfilled (either resolved or rejected).
- Returns
- boolean
Whether the promise has been fulfilled (either resolved or rejected).
isRejected
- Signature
-
isRejected (): boolean
isRejected() may be used to verify whether the promise has been rejected.
- Returns
- boolean
Whether the promise has been rejected.
isResolved
- Signature
-
isResolved (): boolean
isResolved() may be used to verify whether the promise has resolved.
- Returns
- boolean
Whether the promise has 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.
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.
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 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
| 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});