require(["esri/widgets/Home/HomeViewModel"], (HomeVM) => { /* code goes here */ });
import HomeVM from "@arcgis/core/widgets/Home/HomeViewModel.js";
esri/widgets/Home/HomeViewModel
Provides the logic for the Home widget that animates the View to its initial Viewpoint or a previously defined viewpoint.
let homeWidget = new Home({
viewModel: { // autocasts as new HomeViewModel()
view: view
}
}, "homediv"); // References the DOM node used to place the widget
Constructors
-
Parameterproperties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
Name | Type | Summary | Class |
---|---|---|---|
The name of the class. | Accessor | ||
This function provides the ability to override either the MapView goTo() or SceneView goTo() methods. | HomeViewModel | ||
The current state of the widget. | HomeViewModel | ||
The view associated with the widget instance. | HomeViewModel | ||
The Viewpoint, or point of view, to zoom to when going home. | HomeViewModel |
Property Details
-
goToOverride
goToOverride GoToOverride
Since: ArcGIS Maps SDK for JavaScript 4.8HomeViewModel since 4.0, goToOverride added at 4.8. -
This function provides the ability to override either the MapView goTo() or SceneView goTo() methods.
- See also
-
- esri/views/MapView#goTo
- SceneView
Example// The following snippet uses the Search widget 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
state Stringreadonly
-
The current state of the widget.
Possible Values:"disabled" |"ready" |"going-home"
- Default Value:"disabled"
-
The Viewpoint, or point of view, to zoom to when going home. The initial value is determined a few different ways:
- Default Value:null
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;
Method Overview
Name | Return Type | Summary | Class |
---|---|---|---|
Adds one or more handles which are to be tied to the lifecycle of the object. | Accessor | ||
This function provides the ability to interrupt and cancel the process of navigating the view back to the view's initial extent. | HomeViewModel | ||
Emits an event on the instance. | HomeViewModel | ||
Animates the view to the initial Viewpoint of the view or the value of viewpoint. | HomeViewModel | ||
Indicates whether there is an event listener on the instance that matches the provided event name. | HomeViewModel | ||
Returns true if a named group of handles exist. | Accessor | ||
Registers an event handler on the instance. | HomeViewModel | ||
Removes a group of handles owned by the object. | Accessor |
Method Details
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, addHandles added at 4.25. -
Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.
// Manually manage handles const handle = reactiveUtils.when( () => !view.updating, () => { wkidSelect.disabled = false; }, { once: true } ); this.addHandles(handle); // Destroy the object this.destroy();
ParametershandleOrHandles WatchHandle|WatchHandle[]Handles marked for removal once the object is destroyed.
groupKey *optionalKey identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.
-
Since: ArcGIS Maps SDK for JavaScript 4.9HomeViewModel since 4.0, cancelGo added at 4.9. -
This function provides the ability to interrupt and cancel the process of navigating the view back to the view's initial extent.
-
hasHandles
InheritedMethodhasHandles(groupKey){Boolean}
Inherited from AccessorSince: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, hasHandles added at 4.25. -
Returns true if a named group of handles exist.
ParametergroupKey *optionalA group key.
ReturnsType Description Boolean Returns true
if a named group of handles exist.Example// Remove a named group of handles if they exist. if (obj.hasHandles("watch-view-updates")) { obj.removeHandles("watch-view-updates"); }
-
on
on(type, listener){Object}
-
Registers an event handler on the instance. Call this method to hook an event with a listener.
ParametersReturnsType Description Object 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. Exampleview.on("click", function(event){ // event is the event handle returned after the event fires. console.log(event.mapPoint); });
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, removeHandles added at 4.25. -
Removes a group of handles owned by the object.
ParametergroupKey *optionalA group key or an array or collection of group keys to remove.
Exampleobj.removeHandles(); // removes handles from default group obj.removeHandles("handle-group"); obj.removeHandles("other-handle-group");
Event Overview
Name | Type | Summary | Class |
---|---|---|---|
|
Fires when the go() method is called. |
HomeViewModel |