Skip to content
import CompassViewModel from "@arcgis/core/widgets/Compass/CompassViewModel.js";
Inheritance:
CompassViewModelAccessor
Since
ArcGIS Maps SDK for JavaScript 4.0

Provides the logic for the Compass widget and component.

The Compass indicates where north is in relation to the current view MapView.rotation or camera heading. This is added to a SceneView by default.

See also

Constructors

Constructor

Constructor
Parameters
ParameterTypeDescriptionRequired
properties
See the properties table for a list of all the properties that may be passed into the constructor.

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor
Since
ArcGIS Maps SDK for JavaScript 4.7

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

goToOverride

inherited Property
Type
GoToOverride | null | undefined
Inherited from: GoTo
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);
};

orientation

readonly Property
Type
Axes

The z axis orientation.

Default value
{ z: 0 }

state

readonly Property
Type
CompassViewModelState

The view model's state.

Default value
"disabled"

view

Property
Type
MapViewOrSceneView | null | undefined

The view in which the Compass obtains and indicates camera Camera.heading, using a (SceneView) or MapView.rotation (MapView).

Methods

MethodSignatureClass
reset(): void

reset

Method
Signature
reset (): void

If working in a MapView, sets the view's MapView.rotation is to 0. If working in a SceneView, sets the camera's Camera.heading to 0.

This method is executed each time the Compass is clicked.

Returns
void

Type definitions

CompassViewModelState

Type definition
Type
"disabled" | "compass" | "rotation"