import HomeViewModel from "@arcgis/core/widgets/Home/HomeViewModel.js";const HomeViewModel = await $arcgis.import("@arcgis/core/widgets/Home/HomeViewModel.js");- Inheritance:
- HomeViewModel→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 4.0
Provides the logic for the Home widget that animates the View to its initial Viewpoint or a previously defined viewpoint.
- See also
Home component
Home widget - Deprecated since 4.32. Use the Home component instead.
Example
let homeWidget = new Home({ viewModel: { // autocasts as new HomeViewModel() view: view }}, "homediv"); // References the DOM node used to place the widgetConstructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
declaredClass readonly inherited | ||
goToOverride inherited | ||
state readonly | | |
| | ||
| |
goToOverride
- Type
- GoToOverride | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 4.8
This function provides the ability to override either the MapView goTo() or SceneView goTo() methods.
- See also
Example
// The following snippet uses Search but can be applied to any// widgets that support the goToOverride property.search.goToOverride = function(view, goToParams) { goToParams.options = { duration: updatedDuration }; return view.goTo(goToParams.target, goToParams.options);}; state
- Type
- HomeViewModelState
The current state of the widget.
- Default value
- "disabled"
view
- Type
- MapViewOrSceneView | null | undefined
The view associated with the widget instance.
viewpoint
The Viewpoint, or point of view, to zoom to when going home. The initial value is determined a few different ways:
Example
// Creates a viewpoint centered on the extent of a polygon geometrylet vp = new Viewpoint({ targetGeometry: geom.extent});
// Sets the model's viewpoint to the Viewpoint based on a polygon geometryhome.ViewModel.viewpoint = vp;Methods
| Method | Signature | Class |
|---|---|---|
cancelGo(): void | | |
emit inherited | emit<Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean | |
go(): Promise<void> | | |
hasEventListener inherited | hasEventListener<Type extends EventNames<this>>(type: Type): boolean | |
on inherited | on<Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle |
cancelGo
- Signature
-
cancelGo (): void
- Since
- ArcGIS Maps SDK for JavaScript 4.9
This function provides the ability to interrupt and cancel the process of navigating the view back to the view's initial extent.
- Returns
- void
emit
- Signature
-
emit <Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
- Type parameters
- <Type extends EventNames<this>>
- Since
- ArcGIS Maps SDK for JavaScript 4.5
Emits an event on the instance. This method should only be used when creating subclasses of this class.
hasEventListener
- Signature
-
hasEventListener <Type extends EventNames<this>>(type: Type): boolean
- Type parameters
- <Type extends EventNames<this>>
Indicates whether there is an event listener on the instance that matches the provided event name.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| type | Type | The name of the event. | |
- Returns
- boolean
Returns true if the class supports the input event.
on
- Signature
-
on <Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
- Type parameters
- <Type extends EventNames<this>>
Registers an event handler on the instance. Call this method to hook an event with a listener.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| type | Type | An event or an array of events to listen for. | |
| listener | EventedCallback<this["@eventTypes"][Type]> | The function to call when the event fires. | |
- Returns
- ResourceHandle
Returns an event handler with a
remove()method that should be called to stop listening for the event(s).Property Type Description remove Function When called, removes the listener from the event.
Example
view.on("click", function(event){ // event is the event handle returned after the event fires. console.log(event.mapPoint);});Events
| Name | Type |
|---|---|
go
go: CustomEvent<void> Example
homeWidget.on("go", function(event){ console.log("updating viewpoint");});