@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
77 lines (74 loc) • 4.32 kB
TypeScript
import type Basemap from "../../Basemap.js";
import type Accessor from "../../core/Accessor.js";
import type { BasemapProperties } from "../../Basemap.js";
import type { MapViewOrSceneView } from "../../views/MapViewOrSceneView.js";
export interface BasemapToggleViewModelProperties extends Partial<Pick<BasemapToggleViewModel, "view">> {
/**
* The next basemap for toggling. One of the following values may be set to this property:
*
* * The [string ID](https://developers.arcgis.com/javascript/latest/references/core/Map/#basemap) of any Esri basemap.
* * A custom [Basemap](https://developers.arcgis.com/javascript/latest/references/core/Basemap/) object.
*/
nextBasemap?: BasemapProperties | string | null;
}
export type BasemapToggleViewModelState = "ready" | "incompatible-next-basemap" | "loading" | "disabled";
/**
* Provides the logic for the [Basemap Toggle](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-basemap-toggle/) component and [BasemapToggle](https://developers.arcgis.com/javascript/latest/references/core/widgets/BasemapToggle/) widget.
* Use the [nextBasemap](https://developers.arcgis.com/javascript/latest/references/core/widgets/BasemapToggle/BasemapToggleViewModel/#nextBasemap) property to determining the
* secondary basemap to toggle to.
*
* @since 4.0
* @see [Basemap Toggle](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-basemap-toggle/) component
* @see [BasemapToggle](https://developers.arcgis.com/javascript/latest/references/core/widgets/BasemapToggle/) widget - _Deprecated since 4.32. Use the [Basemap Toggle component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-basemap-toggle/) instead._
* @see [Programming patterns: Widget viewModel pattern](https://developers.arcgis.com/javascript/latest/programming-patterns/#widget-viewmodel-pattern)
* @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
* }
* });
*/
export default class BasemapToggleViewModel extends Accessor {
/**
* 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.
*
* @param basemap - The basemap used to retrieve the thumbnail URL.
* @returns The basemap's thumbnail URL.
* @since 4.4
*/
static getThumbnailUrl(basemap: Basemap | null | undefined): string | null | undefined;
constructor(properties?: BasemapToggleViewModelProperties);
/** The map's [Map.basemap](https://developers.arcgis.com/javascript/latest/references/core/Map/#basemap). */
get activeBasemap(): Basemap | null | undefined;
/**
* The next basemap for toggling. One of the following values may be set to this property:
*
* * The [string ID](https://developers.arcgis.com/javascript/latest/references/core/Map/#basemap) of any Esri basemap.
* * A custom [Basemap](https://developers.arcgis.com/javascript/latest/references/core/Basemap/) object.
*/
get nextBasemap(): Basemap | null | undefined;
set nextBasemap(value: BasemapProperties | string | null | undefined);
/**
* The view model's state.
*
* @default "disabled"
*/
get state(): BasemapToggleViewModelState;
/**
* The view from which the component or widget will operate. This view
* provides access to the initial
* [Map.basemap](https://developers.arcgis.com/javascript/latest/references/core/Map/#basemap) to toggle from
* via the view's [View.map](https://developers.arcgis.com/javascript/latest/references/core/views/View/#map) property.
*/
accessor view: MapViewOrSceneView | null | undefined;
/**
* Toggles to the [next basemap](https://developers.arcgis.com/javascript/latest/references/core/widgets/BasemapToggle/BasemapToggleViewModel/#nextBasemap).
*
* @returns Resolves after the basemap has been toggled to the next basemap.
*/
toggle(): Promise<void>;
}