import type { PointerType, MouseButton, ViewEvent, EventDefer, EventDeferredOperation } from "@arcgis/core/views/input/types.js";Type definitions
MouseButton
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates which mouse button was clicked. See MouseEvent.button.
| Value | Description |
|---|---|
| 0 | left click (or touch) |
| 1 | middle click |
| 2 | right click |
| 3 | back click |
| 4 | forward click |
| -1 | unknown button |
- Type
- 0 | 1 | 2 | 3 | 4 | -1
ViewEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Base interface for view input events.
timestamp
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Time stamp (in milliseconds) at which the event was created.
stopPropagation
- Signature
-
stopPropagation (): void
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Prevents the event bubbling up the event chain.
- Returns
- void
defer
- Type
- EventDefer
- Since
- ArcGIS Maps SDK for JavaScript 5.0
A function that can be called to defer event propagation until the passed in asynchronous function is completed. Calling defer will stall the entire event pipeline and should be used with caution.
EventDefer
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| operation | An asynchronous operation. | |
- Returns
- Promise
The result of calling the passed in operation.
EventDeferredOperation
- Type parameters
- <T>
- Since
- ArcGIS Maps SDK for JavaScript 4.33
Aynchronous function passed to the defer method of an event.
- See also
- Returns
- Promise
The event pipeline is deferred until the promise is resolved.
ClickEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Event payload for the view's View.@click event.
- Supertypes
- ViewEvent<PointerEvent | MouseEvent>
button
- Type
- MouseButton
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates which mouse button was clicked.
buttons
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates the current mouse button state.
| Value | Description |
|---|---|
| 0 | left click (or touch) |
| 1 | middle click |
| 2 | right click |
x
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The horizontal screen coordinate of the click on the view.
y
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The vertical screen coordinate of the click on the view.
mapPoint
- Type
- Point
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The point location of the click on the view in the spatial reference of the map.
DoubleClickEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Event payload for the view's View.@double-click event.
- Supertypes
- ViewEvent<PointerEvent | MouseEvent>
button
- Type
- MouseButton
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates which mouse button was clicked.
buttons
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates the current mouse button state.
| Value | Description |
|---|---|
| 0 | left click (or touch) |
| 1 | middle click |
| 2 | right click |
x
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The horizontal screen coordinate of the click on the view.
y
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The vertical screen coordinate of the click on the view.
mapPoint
- Type
- Point
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The point location of the click on the view in the spatial reference of the map.
ImmediateClickEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Event payload for the view's View.@immediate-click event.
- Supertypes
- ViewEvent<PointerEvent | MouseEvent>
button
- Type
- MouseButton
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates which mouse button was clicked. See MouseEvent.button.
| Value | Description |
|---|---|
| 0 | left click (or touch) |
| 1 | middle click |
| 2 | right click |
buttons
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates which buttons are pressed when the event is triggered. See MouseEvent.buttons.
x
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The horizontal screen coordinate of the click on the view.
y
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The vertical screen coordinate of the click on the view.
mapPoint
- Type
- Point
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The point location of the click on the view in the spatial reference of the map.
ImmediateDoubleClickEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Event payload for the view's View.@immediate-double-click event.
- Supertypes
- ViewEvent<PointerEvent | MouseEvent>
button
- Type
- MouseButton
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates which mouse button was clicked. See MouseEvent.button.
| Value | Description |
|---|---|
| 0 | left click (or touch) |
| 1 | middle click |
| 2 | right click |
buttons
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates which buttons are pressed when the event is triggered. See MouseEvent.buttons.
x
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The horizontal screen coordinate of the click on the view.
y
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The vertical screen coordinate of the click on the view.
mapPoint
- Type
- Point
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The point location of the click on the view in the spatial reference of the map.
HoldEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Event payload for the view's View.@hold event.
- Supertypes
- ViewEvent<PointerEvent | MouseEvent>
button
- Type
- MouseButton
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates which mouse button was held down. See MouseEvent.button.
| Value | Description |
|---|---|
| 0 | left mouse button (or touch) |
| 1 | middle mouse button |
| 2 | right mouse button |
buttons
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates which mouse buttons are pressed when the event is triggered. See MouseEvent.buttons.
x
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The horizontal screen coordinate of the hold on the view.
y
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The vertical screen coordinate of the hold on the view.
mapPoint
- Type
- Point
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The point location of the click on the view in the spatial reference of the map.
DragEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Event payload for the view's View.@drag event.
- Supertypes
- ViewEvent<PointerEvent | MouseEvent>
button
- Type
- MouseButton
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates which mouse button was clicked at the start of the drag. See MouseEvent.button.
| Value | Description |
|---|---|
| 0 | left mouse button (or touch) |
| 1 | middle mouse button |
| 2 | right mouse button |
buttons
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates which mouse buttons are pressed when the event is triggered. See MouseEvent.buttons.
x
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The horizontal screen coordinate of the pointer on the view.
y
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The vertical screen coordinate of the pointer on the view.
origin
- Type
- DragEventOrigin
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Screen coordinates of the start of the drag.
angle
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Amount of rotation (in degrees) since the last event of type start.
radius
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The radius of a sphere around the multiple pointers involved in this drag. Or 0 while only a single pointer is used.
DragEventOrigin
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Screen coordinates where a View.@drag started.
x
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The horizontal screen coordinate of the pointer on the view.
y
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The vertical screen coordinate of the pointer on the view.
KeyDownEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Event payload for the view's View.@key-down event.
- Supertypes
- ViewEvent<KeyboardEvent>
repeat
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates whether this is the first event emitted due to the key press, or a repeat.
key
- Type
- string
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The key value that was pressed, according to the MDN full list of key values.
KeyUpEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Event payload for the view's View.@key-up event.
- Supertypes
- ViewEvent<KeyboardEvent>
key
- Type
- string
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The key value that was released, according to the MDN full list of key values.
PointerEventCommon
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Base interface for pointer events emitted by the view.
- Supertypes
- ViewEvent<PointerEvent>
pointerId
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Uniquely identifies a pointer between multiple down, move, and up events. Ids might get reused after a pointer-up event.
pointerType
- Type
- PointerType
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates the pointer type.
button
- Type
- MouseButton
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates which mouse button was clicked.
buttons
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates which mouse buttons are pressed when the event is triggered. See MouseEvent.buttons.
x
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The horizontal screen coordinate of the pointer on the view.
y
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The vertical screen coordinate of the pointer on the view.
PointerDownEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Event payload for the view's View.@pointer-down event.
- Supertypes
- PointerEventCommon
PointerMoveEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Event payload for the view's View.@pointer-move event.
- Supertypes
- PointerEventCommon
PointerUpEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Event payload for the view's View.@pointer-up event.
- Supertypes
- PointerEventCommon
PointerEnterEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Event payload for the view's View.@pointer-enter event.
- Supertypes
- PointerEventCommon
PointerLeaveEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Event payload for the view's View.@pointer-leave event.
- Supertypes
- PointerEventCommon
ViewMouseWheelEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Event payload for the view's View.@mouse-wheel event.
- Supertypes
- ViewEvent<WheelEvent>
x
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The horizontal screen coordinate of the click on the view.
y
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The vertical screen coordinate of the click on the view.
deltaY
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Number representing the vertical scroll amount.
ViewFocusEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Event payload for the view's View.@focus event.
- Supertypes
- ViewEvent<FocusEvent>
ViewBlurEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Event payload for the view's View.@blur event.
- Supertypes
- ViewEvent<FocusEvent>
ViewResizeEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Event payload for the view's View.@resize event.
oldWidth
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The previous view width in pixels
oldHeight
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The previous view height in pixels
width
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The new measured view width in pixels
height
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The new measured view height in pixels
LayerViewCreateEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Event payload for the view's View.@layerview-create event.
layer
- Type
- Layer
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The layer in the map for which the layerView was created.
layerView
- Type
- LayerView
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The LayerView rendered
in the view representing the layer in layer.
LayerViewCreateErrorEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Event payload for the view's View.@layerview-create-error event.
layer
- Type
- Layer
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The layer in the map for which the view emitting this event failed to create a layer view.
error
- Type
- Error
- Since
- ArcGIS Maps SDK for JavaScript 5.0
An error object describing why the layer view could not be created.
LayerViewDestroyEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Event payload for the view's View.@layerview-destroy event.
layer
- Type
- Layer
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The layer in the map for which the layerView was destroyed.
layerView
- Type
- LayerView
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The LayerView that was destroyed in the view.
DoubleTapDragEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Event payload for the view's View.@double-tap-drag event.
- Supertypes
- ViewEvent<PointerEvent | MouseEvent>
button
- Type
- MouseButton
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates which mouse button was clicked at the start of the drag. See MouseEvent.button.
| Value | Description |
|---|---|
| 0 | left mouse button (or touch) |
| 1 | middle mouse button |
| 2 | right mouse button |
buttons
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates which mouse buttons are pressed when the event is triggered. See MouseEvent.buttons.
x
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The horizontal distance from the drag origin in pixels.
y
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The vertical distance from the drag origin in pixels.
VerticalTwoFingerDragEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Event payload for the view's View.@vertical-two-finger-drag event.
- Supertypes
- ViewEvent<PointerEvent | MouseEvent>
y
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The vertical distance from the drag origin in pixels.
ViewBaseEventTypes
- Since
- ArcGIS Maps SDK for JavaScript 5.0
resize
- Type
- ViewResizeEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires when the view's size changes.
layerview-create
- Type
- LayerViewCreateEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after each layer in the map has a corresponding LayerView created and rendered in the view.
- See also
- Example
- // This function fires each time a layer view is created for a layer in// the map of the view.view.on("layerview-create", function(event) {// The event contains the layer and its layer view that has just been// created. Here we check for the creation of a layer view for a layer with// a specific id, and log the layer viewif (event.layer.id === "satellite") {// The LayerView for the desired layerconsole.log(event.layerView);}});
layerview-create-error
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires when an error occurs during the creation of a LayerView after a layer has been added to the map.
- See also
- Example
- // This function fires each time an error occurs during the creation of a layerviewview.on("layerview-create-error", function(event) {console.error("LayerView failed to create for layer with the id: ", event.layer.id);});
layerview-destroy
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after a LayerView is destroyed and is no longer rendered in the view. This happens for example when a layer is removed from the map of the view.
ViewEventTypes
- Since
- ArcGIS Maps SDK for JavaScript 5.0
- Supertypes
- ViewBaseEventTypes
click
- Type
- ClickEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after a user clicks on the view. This event emits slightly slower than an View.@immediate-click event to make sure that a View.@double-click event isn't triggered instead. The View.@immediate-click event can be used for responding to a click event without delay.
- Examples
- view.on("click", function(event){// event is the event object returned after the event fires// Prints the map coordinates of the clicked locationconsole.log(event.mapPoint);});// Set up a click event handler and retrieve the screen pointview.on("click", function(event) {// the hitTest() checks to see if any graphics in the view// intersect the given screen x, y coordinatesview.hitTest(event).then(getGraphics);});view.on("click", function(event) {// you must overwrite default click-for-popup// behavior to display your own popupview.popupEnabled = false;// Get the coordinates of the click on the viewlet lat = Math.round(event.mapPoint.latitude * 1000) / 1000;let lon = Math.round(event.mapPoint.longitude * 1000) / 1000;view.popup.open({// Set the popup's title to the coordinates of the locationtitle: "Reverse geocode: [" + lon + ", " + lat + "]",location: event.mapPoint // Set the location of the popup to the clicked locationcontent: "This is a point of interest" // content displayed in the popup});});
double-click
- Type
- DoubleClickEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after double-clicking on the view.
- Example
- view.on("double-click", function(event) {// The event object contains the mapPoint and the screen coordinates of the location// that was clicked.console.log("screen point", event.x, event.y);console.log("map point", event.mapPoint);});
immediate-click
- Type
- ImmediateClickEvent
Fires right after a user clicks on the view. In contrast to the View.@click event,
the immediate-click event is emitted as soon as the user clicks on
the view, and is not inhibited by a View.@double-click event. This event
is useful for interactive experiences that require feedback without delay.
- Example
- // Set up an immediate-click event handler and retrieve the screen pointview.on("immediate-click", function(event) {// the hitTest() checks to see if any graphics in the view// intersect the given screen x, y coordinatesview.hitTest(event).then(getGraphics);});
immediate-double-click
Is emitted after two consecutive View.@immediate-click events.
In contrast to View.@double-click, an immediate-double-click cannot
be prevented by use of stopPropagation on the View.@immediate-click
event and can therefore be used to react to double-clicking independently of usage of the
View.@immediate-click event.
hold
- Type
- HoldEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after holding either a mouse button or a single finger on the view for a short amount of time.
- Example
- view.on("hold", function(event) {// The event object contains the mapPoint and the screen coordinates of the location// that was clicked.console.log("hold at screen point", event.x, event.y);console.log("hold at map point", event.mapPoint);});
drag
- Type
- DragEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires during a pointer drag on the view.
- Example
- view.on("drag", function(event){// Print out the current state of the// drag event.console.log("drag state", event.action);});
key-down
- Type
- KeyDownEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after a keyboard key is pressed.
- Example
- // Zoom in when user clicks on "a" button// Zoom out when user clicks on "s" buttonview.on("key-down", function(event){console.log("key-down", event);if (event.key === "a"){let zm = view.zoom + 1;view.goTo({target: view.center,zoom: zm});}else if(event.key == "s"){let zm = view.zoom - 1;view.goTo({target: view.center,zoom: zm});}});
key-up
- Type
- KeyUpEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after a keyboard key is released.
pointer-down
- Type
- PointerDownEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after a mouse button is pressed, or a finger touches the display.
pointer-move
- Type
- PointerMoveEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after the mouse or a finger on the display moves.
- Example
- // Fires `pointer-move` event when user clicks on "Shift"// key and moves the pointer on the view.view.on('pointer-move', ["Shift"], function(event){let point = view.toMap({x: event.x, y: event.y});bufferPoint(point);});
pointer-up
- Type
- PointerUpEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after a mouse button is released, or a display touch ends.
pointer-enter
- Type
- PointerEnterEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after a mouse cursor enters the view, or a display touch begins.
pointer-leave
- Type
- PointerLeaveEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after a mouse cursor leaves the view, or a display touch ends.
mouse-wheel
- Type
- ViewMouseWheelEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires when a wheel button of a pointing device (typically a mouse) is scrolled on the view.
- Example
- view.on("mouse-wheel", function(event){// deltaY value is positive when wheel is scrolled up// and it is negative when wheel is scrolled down.console.log(event.deltaY);});
double-tap-drag
- Type
- DoubleTapDragEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires while the pointer is drag following a double-tap gesture on the view.
- Example
- view.on("double-tap-drag", (event) => {// Display the distance moved from the drag origin.console.log("x distance:", event.x, "y distance:", event.y);});