Skip to content
import BasemapToggleViewModel from "@arcgis/core/widgets/BasemapToggle/BasemapToggleViewModel.js";
Inheritance:
BasemapToggleViewModelAccessor
Since
ArcGIS Maps SDK for JavaScript 4.0

Provides the logic for the Basemap Toggle component and BasemapToggle widget. Use the nextBasemap property to determining the secondary basemap to toggle to.

See also
Example
let basemapToggle = new BasemapToggle({
viewModel: { // autocasts as new BasemapToggleViewModel()
view: view, // view with map that uses "streets-vector" basemap
nextBasemap: "hybrid" // Allows for toggling to "hybrid" basemap
}
});

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.

activeBasemap

readonly Property
Type
Basemap | null | undefined

The map's Map.basemap.

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.

nextBasemap

autocast Property
Type
Basemap | null | undefined

The next basemap for toggling. One of the following values may be set to this property:

state

readonly Property
Type
BasemapToggleViewModelState

The view model's state.

Default value
"disabled"

view

Property
Type
MapViewOrSceneView | null | undefined

The view from which the component or widget will operate. This view provides access to the initial Map.basemap to toggle from via the view's View.map property.

Methods

MethodSignatureClass
getThumbnailUrl(basemap: Basemap | null | undefined): string | null | undefined
toggle(): Promise<void>

getThumbnailUrl

static Method
Signature
getThumbnailUrl (basemap: Basemap | null | undefined): string | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.4

Helper method to find a basemap's thumbnail URL.

If the basemap does not have a thumbnail URL defined, this utility will try to find a thumbnail URL from the best matching well-known basemap. If no match is found, a thumbnail URL from the basemap's base layers will be used.

Parameters
ParameterTypeDescriptionRequired
basemap

The basemap used to retrieve the thumbnail URL.

Returns
string | null | undefined

The basemap's thumbnail URL.

toggle

Method
Signature
toggle (): Promise<void>

Toggles to the next basemap.

Returns
Promise<void>

Resolves after the basemap has been toggled to the next basemap.

Type definitions

BasemapToggleViewModelState

Type definition
Type
"ready" | "incompatible-next-basemap" | "loading" | "disabled"