@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
110 lines (106 loc) • 6.5 kB
TypeScript
import type Viewpoint from "../../Viewpoint.js";
import type { EventedAccessor } from "../../core/Evented.js";
import type { MapViewOrSceneView } from "../../views/MapViewOrSceneView.js";
import type { GoTo, GoToProperties } from "../support/GoTo.js";
import type { ViewpointProperties } from "../../Viewpoint.js";
export interface HomeViewModelProperties extends GoToProperties, Partial<Pick<HomeViewModel, "view">> {
/**
* The [Viewpoint](https://developers.arcgis.com/javascript/latest/references/core/Viewpoint/), or point of view, to zoom to when
* going home. The initial value is determined a few different ways:
*
* * If no [View](https://developers.arcgis.com/javascript/latest/references/core/views/View/) is provided, the value is `null`.
* * If the [View](https://developers.arcgis.com/javascript/latest/references/core/views/View/) is ready, but the [Viewpoint](https://developers.arcgis.com/javascript/latest/references/core/Viewpoint/) is not defined, the initial
* value of the [Viewpoint](https://developers.arcgis.com/javascript/latest/references/core/Viewpoint/) is determined when the [View](https://developers.arcgis.com/javascript/latest/references/core/views/View/) became ready.
* * If the [View](https://developers.arcgis.com/javascript/latest/references/core/views/View/) is ready and the [Viewpoint](https://developers.arcgis.com/javascript/latest/references/core/Viewpoint/) is defined by the user, the initial viewpoint value is the user-defined [Viewpoint](https://developers.arcgis.com/javascript/latest/references/core/Viewpoint/).
*
* @example
* // Creates a viewpoint centered on the extent of a polygon geometry
* let vp = new Viewpoint({
* targetGeometry: geom.extent
* });
*
* // Sets the model's viewpoint to the Viewpoint based on a polygon geometry
* home.ViewModel.viewpoint = vp;
*/
viewpoint?: ViewpointProperties | null;
}
export type HomeViewModelState = "disabled" | "going-home" | "ready";
export interface HomeViewModelEvents {
/**
* Fires when the [Home.go()](https://developers.arcgis.com/javascript/latest/references/core/widgets/Home/#go) method is called.
*
* @see [Home.go()](https://developers.arcgis.com/javascript/latest/references/core/widgets/Home/#go)
* @example
* homeWidget.on("go", function(event){
* console.log("updating viewpoint");
* });
*/
go: void;
}
/**
* Provides the logic for the [Home](https://developers.arcgis.com/javascript/latest/references/core/widgets/Home/) widget that
* animates the [View](https://developers.arcgis.com/javascript/latest/references/core/views/View/) to its
* initial [Viewpoint](https://developers.arcgis.com/javascript/latest/references/core/Viewpoint/) or a previously defined [viewpoint](https://developers.arcgis.com/javascript/latest/references/core/widgets/Home/HomeViewModel/#viewpoint).
*
* @deprecated since 5.0. Use the [Home component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-home/) directly instead.
* @since 4.0
* @see [Home](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-home/) component
* @see [Home](https://developers.arcgis.com/javascript/latest/references/core/widgets/Home/) widget - _Deprecated since 4.32. Use the [Home component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-home/) instead._
* @see [Programming patterns: Widget viewModel pattern](https://developers.arcgis.com/javascript/latest/programming-patterns/#widget-viewmodel-pattern)
* @example
* let homeWidget = new Home({
* viewModel: { // autocasts as new HomeViewModel()
* view: view
* }
* }, "homediv"); // References the DOM node used to place the widget
*/
export default class HomeViewModel extends HomeViewModelSuperclass {
/**
* @deprecated
* Do not directly reference this property.
* Use EventNames and EventTypes helpers from \@arcgis/core/Evented
*/
"@eventTypes": HomeViewModelEvents;
constructor(properties?: HomeViewModelProperties);
/**
* The current state of the widget.
*
* @default "disabled"
*/
get state(): HomeViewModelState;
/** The view associated with the widget instance. */
accessor view: MapViewOrSceneView | null | undefined;
/**
* The [Viewpoint](https://developers.arcgis.com/javascript/latest/references/core/Viewpoint/), or point of view, to zoom to when
* going home. The initial value is determined a few different ways:
*
* * If no [View](https://developers.arcgis.com/javascript/latest/references/core/views/View/) is provided, the value is `null`.
* * If the [View](https://developers.arcgis.com/javascript/latest/references/core/views/View/) is ready, but the [Viewpoint](https://developers.arcgis.com/javascript/latest/references/core/Viewpoint/) is not defined, the initial
* value of the [Viewpoint](https://developers.arcgis.com/javascript/latest/references/core/Viewpoint/) is determined when the [View](https://developers.arcgis.com/javascript/latest/references/core/views/View/) became ready.
* * If the [View](https://developers.arcgis.com/javascript/latest/references/core/views/View/) is ready and the [Viewpoint](https://developers.arcgis.com/javascript/latest/references/core/Viewpoint/) is defined by the user, the initial viewpoint value is the user-defined [Viewpoint](https://developers.arcgis.com/javascript/latest/references/core/Viewpoint/).
*
* @example
* // Creates a viewpoint centered on the extent of a polygon geometry
* let vp = new Viewpoint({
* targetGeometry: geom.extent
* });
*
* // Sets the model's viewpoint to the Viewpoint based on a polygon geometry
* home.ViewModel.viewpoint = vp;
*/
get viewpoint(): Viewpoint | null | undefined;
set viewpoint(value: ViewpointProperties | null | undefined);
/**
* This function provides the ability to interrupt and cancel the process
* of navigating the view back to the view's initial extent.
*
* @since 4.9
*/
cancelGo(): void;
/**
* Animates the view to the initial [Viewpoint](https://developers.arcgis.com/javascript/latest/references/core/Viewpoint/) of the view or the
* value of [viewpoint](https://developers.arcgis.com/javascript/latest/references/core/widgets/Home/HomeViewModel/#viewpoint).
*/
go(): Promise<void>;
}
declare const HomeViewModelSuperclass: typeof EventedAccessor & typeof GoTo