import SelectionOperation from "@arcgis/core/views/selection/SelectionOperation.js";
Inheritance
SelectionOperationAccessor
Since
ArcGIS Maps SDK for JavaScript 5.1

The selection operation is responsible for creating and using an interactive drawing tool to maintain an interactively updated graphics selection set while a selection area is being drawn. The interactive tool is active on the view when the operation is created. After the operation is completed (selection area is finalized or cancelled), the interactive tool is removed. Each operation can only be used once and a new selection operation should be created each time a new selection is required.

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.

completed

readonly Property
Type
boolean

Indicates whether the selection operation has been completed or cancelled.

createTool

readonly Property
Type
SelectionOperationCreateTool

The type of drawing tool being used by this selection operation.

Default value
"rectangle"

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.

effectiveSelectionManager

readonly Property
Type
SelectionManager

The selection manager being used by this selection operation.

effectiveType

readonly Property
Type
SelectionOperationType

The current effective type of the selection operation. Accounts for modifications to the active type when holding a constraint key (Control or Meta).

mode

readonly Property
Type
DrawingMode | null | undefined

Indicates the draw mode being used by this selection operation.

persistSelection

Property
Type
boolean

Indicates whether the selection operation will persist the determined selection via the current effective selection manager.

Default value
true

processingFinalSelection

readonly Property
Type
boolean

Indicates whether the selection operation is determining the final selection set.

returnFeatureTitleFields

Property
Type
boolean

Indicates whether the selection operation should return graphics with attributes required to determine a title for individual selected features.

Default value
false

returnGeometry

Property
Type
boolean

Indicates whether the selection operation should return graphics with geometries when determining the selection.

Default value
true

selection

readonly Property
Type
Collection<Graphic>

A reference to the current working selection while actively drawing.

selectionManager

readonly Property
Type
SelectionManager | null | undefined

A reference to a custom selection manager. Otherwise, the selection operation uses the selection manager on the provided view.

selectOnComplete

readonly Property
Type
boolean

Indicates whether the selection operation should only update the selection when the operation successfully completes, rather than while actively drawing.

Default value
true

sources

Property
Type
SelectionSource[] | null | undefined

A reference to sources that should be used to determine selections.

toolName

readonly Property
Type
SelectionToolName

Reference to the current drawing tool being used by the selection operation.

Default value
""

type

Property
Type
SelectionOperationType

Reference to the current type of selection operation.

Default value
"add"

view

readonly Property
Type
SelectableViewUnion

Reference to the view being used by the selection operation.

Methods

MethodSignatureClass
cancel(): void
destroy(): void
inherited
emit<Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
inherited
hasEventListener<Type extends EventNames<this>>(type: Type): boolean
on
inherited
on<Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle

cancel

Method
Signature
cancel (): void

Cancels the selection operation. Any existing selection identified by the operation is cleared.

Returns
void

destroy

Method
Signature
destroy (): void

Destroys the selection operation.

Returns
void

emit

inherited Method
Signature
emit <Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin
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.

Parameters

ParameterTypeDescriptionRequired
type
Type

The name of the event.

event
this["@eventTypes"][Type]

The event payload.

Returns
boolean

true if a listener was notified

hasEventListener

inherited Method
Signature
hasEventListener <Type extends EventNames<this>>(type: Type): boolean
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin

Indicates whether there is an event listener on the instance that matches the provided event name.

Parameters

ParameterTypeDescriptionRequired
type
Type

The name of the event.

Returns
boolean

Returns true if the class supports the input event.

on

inherited Method
Signature
on <Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin

Registers an event handler on the instance. Call this method to hook an event with a listener.

Parameters

ParameterTypeDescriptionRequired
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).

PropertyTypeDescription
removeFunctionWhen 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);
});