import BasemapToggleViewModel from "@arcgis/core/widgets/BasemapToggle/BasemapToggleViewModel.js";const BasemapToggleViewModel = await $arcgis.import("@arcgis/core/widgets/BasemapToggle/BasemapToggleViewModel.js");- Inheritance:
- BasemapToggleViewModel→
Accessor
- 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
Basemap Toggle component
BasemapToggle widget - Deprecated since 4.32. Use the Basemap Toggle component instead.
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
| Parameter | Type | Description | Required |
|---|---|---|---|
| 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.
| Property | Type | Class |
|---|---|---|
activeBasemap readonly | | |
declaredClass readonly inherited | ||
| | ||
state readonly | | |
| |
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
| Method | Signature | Class |
|---|---|---|
getThumbnailUrl static | 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.