DirectionalPadViewModel

AMD: require(["esri/widgets/DirectionalPad/DirectionalPadViewModel"], (DirectionalPadVM) => { /* code goes here */ });
ESM: import DirectionalPadVM from "@arcgis/core/widgets/DirectionalPad/DirectionalPadViewModel.js";
Class: esri/widgets/DirectionalPad/DirectionalPadViewModel
Inheritance: DirectionalPadViewModel Accessor
Since: ArcGIS Maps SDK for JavaScript 4.29

Provides the logic for the DirectionalPad widget.

See also

Constructors

DirectionalPadViewModel

Constructor
new DirectionalPadViewModel(properties)
Parameter
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
Show inherited properties Hide inherited properties
Name Type Summary Class

The closest angle that matches the current mouse position relative to the widget's center.

DirectionalPadViewModel

The name of the class.

Accessor

Indicates whether interaction is allowed on the widget.

DirectionalPadViewModel

The angle of rotation of the map.

DirectionalPadViewModel

The state of the view model.

DirectionalPadViewModel

Property Details

angle

Property
angle Number |undefinedreadonly

The closest angle that matches the current mouse position relative to the widget's center. There are eight possible angles, -45, 0, 45, -90, 90, -135, 180, and 135. If the widget is not in motion, the value is undefined.

declaredClass

Inherited
Property
declaredClass Stringreadonly
Inherited from Accessor

The name of the class. The declared class name is formatted as esri.folder.className.

disabled

Property
disabled Boolean

Indicates whether interaction is allowed on the widget. When true, this property sets the widget to a disabled state to stop user interaction.

Default Value:false

rotation

Property
rotation Number

The angle of rotation of the map. Ranges from 0 to 360

Default Value:0
Example
reactiveUtils.watch(
 ()=>directionalPadViewModel.rotation,
 (newAngle,oldAngle)=> console.log({ newAngle, oldAngle })
);

state

Property
state Stringreadonly

The state of the view model.

Possible Values:"disabled" |"ready" |"moving"

Method Overview

Show inherited methods Hide inherited methods
Name Return Type Summary Class

Adds one or more handles which are to be tied to the lifecycle of the object.

Accessor

Starts movement in the correct direction according to pointer location, and listens for pointer move (to change direction) or release (to stop movement) This method should be called in response to pointerdown event on a button

DirectionalPadViewModel

Returns true if a named group of handles exist.

Accessor

Initialize a brief movement in a desired direction

DirectionalPadViewModel

Removes a group of handles owned by the object.

Accessor

Method Details

addHandles

Inherited
Method
addHandles(handleOrHandles, groupKey)
Inherited from Accessor

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();
Parameters
handleOrHandles WatchHandle|WatchHandle[]

Handles marked for removal once the object is destroyed.

groupKey *
optional

Key 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.

beginFollowingPointer

Method
beginFollowingPointer(pointerLocation, widgetCenter)

Starts movement in the correct direction according to pointer location, and listens for pointer move (to change direction) or release (to stop movement)

This method should be called in response to pointerdown event on a button

Parameters
pointerLocation Vector

Current pointer location

widgetCenter Vector

The center of the DirectionalPad widget

Example
moveLeftButton.addEventListener("pointerDown", (event) => {
  const { x, y, width, height } = buttonsContainer.getBoundingClientRect();
  const widgetCenter = { x: x + width / 2, y: y + height / 2 };
  directionalPadViewModel.beginFollowingPointer(event, widgetCenter);
});

hasHandles

Inherited
Method
hasHandles(groupKey){Boolean}
Inherited from Accessor

Returns true if a named group of handles exist.

Parameter
groupKey *
optional

A group key.

Returns
Type 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");
}

moveOnce

Method
moveOnce(angle)

Initialize a brief movement in a desired direction

Parameter
angle Number

Angle in the [0, 360] range

Example
moveLeftButton.addEventListener("keydown", () => {
  directionalPadViewModel.moveOnce(90);
});

removeHandles

Inherited
Method
removeHandles(groupKey)
Inherited from Accessor

Removes a group of handles owned by the object.

Parameter
groupKey *
optional

A group key or an array or collection of group keys to remove.

Example
obj.removeHandles(); // removes handles from default group

obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");

Type Definitions

Vector

Type Definition
Vector

An x/y coordinate pair. Could be used to represent a screen point or a vector.

Properties
x Number
optional

X coordinate

y Number
optional

Y coordinate

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.