▾
import "@arcgis/map-components/components/arcgis-selection-toolbar";- Inheritance
- ArcgisSelectionToolbar→
HTMLElement
- Since
- ArcGIS Maps SDK for JavaScript 5.2
The selection toolbar component can be used to modify selected features on a provided MapView or SceneView. It provides an interface for performing selection operations such as adding, removing, or replacing selected features. This component can be used in conjunction with other components, such as arcgis-selection-list and arcgis-feature-table.
Demo
Properties
| Property | Attribute | Type |
|---|---|---|
| readonly | | |
| auto-destroy-disabled | ||
| | ||
| continuous-selection-enabled | ||
| | ||
| default-operation-type | ||
| | ||
| | ||
| | ||
| reflected | disabled | |
| readonly | | |
| readonly | | |
| hide-chip | ||
| hide-chip-close-button | ||
| hide-lasso-tool | ||
| hide-operation-type-controls | ||
| hide-pan-tool | ||
| hide-point-tool | ||
| hide-polygon-tool | ||
| hide-progress | ||
| hide-rectangle-tool | ||
| icon | ||
| ignore-layer-visibility | ||
| label | ||
| layer-preference-enabled | ||
| reference-element | ||
| return-feature-title-fields | ||
| return-geometry-disabled | ||
| | ||
| | ||
| readonly | | "active" | "disabled" | "ready" |
| sync-results-disabled | ||
| sync-while-drawing | ||
| | ||
| visual-scale | Action["scale"] |
activeOperation
- Type
- SelectionOperation | null | undefined
A reference to the active selection operation. Only one selection operation can be active at a time.
autoDestroyDisabled
- Type
- boolean
If true, the component will not be destroyed automatically when it is disconnected from the document. This is useful when you want to move the component to a different place on the page, or temporarily hide it. If this is set, make sure to call the destroy() method when you are done to prevent memory leaks.
- Attribute
- auto-destroy-disabled
- Default value
- false
- Example
- <arcgis-selection-toolbar auto-destroy-disabled></arcgis-selection-toolbar>selectionToolbarElement.autoDestroyDisabled = true;
availableOperationTypes
- Type
- SelectionOperationType[]
An array of selection operation type names that determines what operation types appear in the associated dropdown component.
continuousSelectionEnabled
- Type
- boolean
Determines if the selection toolbar should automatically reactivate a new selection operation after the completion of an active selection operation, using options from the previous operation. This only applies if the previous selection operation was completed, and not canceled.
- Attribute
- continuous-selection-enabled
- Default value
- false
defaultOperationType
The default selection operation type to use when starting a new selection operation. This value can be changed via the selection operation type dropdown.
- Attribute
- default-operation-type
- Default value
- "add"
disabled
- Type
- boolean
When true, the component is visually de-emphasized and does not accept user interaction.
- Attribute
- disabled
- Default value
- false
effectiveSelectionManager
- Type
- SelectionManager | null | undefined
A reference to the selection manager currently in use by the component.
effectiveSources
- Type
- Array<SelectionSource>
An array of validated selection sources. These sources will also include any relevant layer views that were found on the provided view if layerPreferenceEnabled is false.
hideChip
- Type
- boolean
Indicates whether the selection count chip should be hidden. The chip shows the total
count of selected features and a close button for clearing the selection.
- Attribute
- hide-chip
- Default value
- false
hideChipCloseButton
- Type
- boolean
Indicates whether the 'close' button on the selection count chip should be hidden. The 'close' button allows users to clear the current selection.
- Attribute
- hide-chip-close-button
- Default value
- false
hideLassoTool
- Type
- boolean
Indicates whether the lasso tool should be hidden. The lasso tool allows for freehand selection of features.
- Attribute
- hide-lasso-tool
- Default value
- false
hideOperationTypeControls
- Type
- boolean
Indicates whether the selection operation type controls should be hidden. The operation type controls
allow for changing the selection operation type (e.g., replace, add, remove).
- Attribute
- hide-operation-type-controls
- Default value
- false
hidePanTool
- Type
- boolean
Indicates whether the pan tool is hidden. The pan tool allows users to navigate the view without initiating a selection operation and is active by default when no selection operation is in progress.
- Attribute
- hide-pan-tool
- Default value
- false
hidePointTool
- Type
- boolean
Indicates whether the point tool should be hidden. The point tool allows for selecting features by clicking on them. The point tool will include all features that intersect the selected point, rather than only the top-most feature.
- Attribute
- hide-point-tool
- Default value
- false
hidePolygonTool
- Type
- boolean
Indicates whether the polygon tool should be hidden. The polygon tool allows for selecting features by drawing a polygon.
- Attribute
- hide-polygon-tool
- Default value
- false
hideProgress
- Type
- boolean
Indicates whether the progress indicator should be hidden.
The progress indicator shows when a selection operation is processing results. The processing time can vary depending on the potential number of selected features, or whether the selection operation is querying source layers or layer views for results.
- Attribute
- hide-progress
- Default value
- false
hideRectangleTool
- Type
- boolean
Indicates whether the rectangle selection tool is hidden. The rectangle tool allows users to select features by drawing a rectangular area.
- Attribute
- hide-rectangle-tool
- Default value
- false
ignoreLayerVisibility
- Type
- boolean
Indicates whether the selection toolbar will ignore layer visibility when determining selection results. Non-visible layers and layer views are typically excluded from selection results.
- Attribute
- ignore-layer-visibility
- Default value
- false
layerPreferenceEnabled
- Type
- boolean
Indicates whether selection operations should always query source layers rather than their associated layer views when determining selection results. Querying the source layer may be necessary when the most up-to-date feature data is required. Changing this property while a selection operation is in progress will not affect the active operation. The change will apply only to subsequent operations.
- Attribute
- layer-preference-enabled
- Default value
- false
referenceElement
- Type
- ArcgisReferenceElement | string | undefined
By assigning the id attribute of the Map or Scene component to this property, you can position a child component anywhere in the DOM while still maintaining a connection to the Map or Scene.
- Attribute
- reference-element
returnFeatureTitleFields
- Type
- boolean
Determines whether selected features include the fields required to display feature titles as defined by the web map.
When enabled, these fields are available on features returned by selection events. They are not stored in the selection manager, which stores only selected feature Object IDs.
Enabling this property may require additional queries and can affect selection performance.
- Attribute
- return-feature-title-fields
- Default value
- false
returnGeometryDisabled
- Type
- boolean
Indicates whether to omit feature geometries from features returned by selection events. Disable this property when selected feature geometries are needed by an application.
Geometries are not stored in the selection manager, which stores only selected feature Object IDs.
Disabling geometry results may improve selection performance when geometries are not needed.
- Attribute
- return-geometry-disabled
- Default value
- false
selectionManager
- Type
- SelectionManager | null | undefined
A reference to a custom selection manager to use instead of the view's default selection manager.
When using a custom selection manager, ensure its sources include the layers and tables that should participate in a selection. Call syncSources() after adding or removing layers from the view.
sources
- Type
- Array<SelectionSource> | null | undefined
An array of layers or layer views used to determine the selection.
syncResultsDisabled
- Type
- boolean
Indicates whether results from new selection operations are not automatically synchronized with the associated selection manager. When set to true, events emitted by the selection-toolbar will still include the updated selection results, but the associated selection manager will not be updated when the selection operation completes.
- Attribute
- sync-results-disabled
- Default value
- false
syncWhileDrawing
- Type
- boolean
Indicates whether the selection operation continuously evaluates the potential
selection while the associated draw tool is active and emits updates through events.
When set to false, the selection is evaluated only once after drawing is complete.
Potential selection results are not stored or reflected by the associated selection manager. Set this property to true to receive continuous updates to the working
selection set, such as for highlighting potential features while drawing. This
property does not control whether the final selection results are stored by the
selection manager; use syncResultsDisabled for that
behavior.
- Attribute
- sync-while-drawing
- Default value
- false
view
- Type
- SelectableViewUnion | null | undefined
The view associated with the component.
Note: The recommended approach is to fully migrate applications to use map and scene components and avoid using MapView and SceneView directly. However, if you are migrating a large application from widgets to components, you might prefer a more gradual transition. To support this use case, the SDK includes this
viewproperty which connects a component to a MapView or SceneView. Ultimately, once migration is complete, the arcgis-selection-toolbar component will be associated with a map or scene component rather than using theviewproperty.
visualScale
- Type
- Action["scale"]
Controls the scale of any rendered Calcite elements.
- Attribute
- visual-scale
- Default value
- "m"
Methods
| Method | Signature |
|---|---|
| activate(options?: SelectionOperationProperties): Promise<SelectionOperation | undefined> | |
| activateTool(toolName: SelectionToolName): Promise<SelectionOperation | undefined> | |
| cancel(): Promise<void> | |
| inherited | componentOnReady(): Promise<this> |
| destroy(): Promise<void> | |
| syncSources(): Promise<void> | |
| toggleTool(toolName: SelectionToolName): Promise<SelectionOperation | undefined> |
activate
- Signature
-
activate (options?: SelectionOperationProperties): Promise<SelectionOperation | undefined>
Activates the specified tool using the provided options and cancels any active selection operation. This method has no effect when the toolbar is disabled.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| options | Optional tool and operation configuration. | |
- Returns
- Promise<SelectionOperation | undefined>
A promise that resolves to the active selection operation, or
undefinedif activation was blocked.
- Example
// Once the selection-toolbar is ready, activate the lasso tool and "replace" operation type
const viewElement = document.querySelector("arcgis-map");const selectionToolbar = document.querySelector("arcgis-selection-toolbar");await viewElement.viewOnReady();await selectionToolbar.componentOnReady();await selectionToolbar.activate({toolName: "lasso",type: "replace"});
activateTool
- Signature
-
activateTool (toolName: SelectionToolName): Promise<SelectionOperation | undefined>
Activates the specified tool by name and cancels any selection operation. This method has no effect when the toolbar is disabled.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| toolName | The name of the tool to activate. | |
- Returns
- Promise<SelectionOperation | undefined>
A promise that resolves to the active selection operation, or
undefinedif activation was blocked.
- Example
// Once the selection-toolbar is ready, activate the rectangle tool
const viewElement = document.querySelector("arcgis-map");const selectionToolbar = document.querySelector("arcgis-selection-toolbar");await viewElement.viewOnReady();await selectionToolbar.componentOnReady();await selectionToolbar.activateTool("rectangle");
componentOnReady
- Signature
-
componentOnReady (): Promise<this>
Creates a promise that resolves once the component is fully loaded.
- Returns
- Promise<this>
- Example
- const arcgisSelectionToolbar = document.createElement("arcgis-selection-toolbar");document.body.append(arcgisSelectionToolbar);await arcgisSelectionToolbar.componentOnReady();console.log("arcgis-selection-toolbar is ready to go!");
syncSources
- Signature
-
syncSources (): Promise<void>
Synchronizes the effective selection manager with the current layers and tables in the view.
Call this method after adding or removing layers or tables from the view, especially when using a custom selection manager. Newly added sources are otherwise excluded from selection results.
This method has no effect if the effective selection manager does not have an assigned view.
toggleTool
- Signature
-
toggleTool (toolName: SelectionToolName): Promise<SelectionOperation | undefined>
Toggles the active state of the specified tool. If the tool is currently active, it is canceled. Otherwise, the tool is activated after canceling any active selection operation.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| toolName | The name of the tool to toggle. | |
- Returns
- Promise<SelectionOperation | undefined>
A promise that resolves to the active selection operation if the associated tool was toggled on, or
undefinedif the tool was toggled off.
Events
| Name | Type |
|---|---|
| CustomEvent<SelectionToolbarViewModelEvents["before-activate"]> | |
| CustomEvent<SelectionToolbarViewModelEvents["complete"]> | |
| CustomEvent<{ name: "activeOperation" | "state"; }> | |
| CustomEvent<SelectionToolbarViewModelEvents["selection-change"]> |
arcgisBeforeActivate
arcgisBeforeActivate: CustomEvent<SelectionToolbarViewModelEvents["before-activate"]> Fires before any selection operation is activated.
- Example
- const toolbar = document.querySelector("arcgis-selection-toolbar");toolbar.addEventListener("arcgisBeforeActivate", (event) => {const { toolName } = event.detail.detail;console.log("Starting selection tool:", toolName);});
arcgisClear
arcgisClear: CustomEvent<void> Fires when the active selection is cleared via the close button on the selection count chip. This event does not fire when the selection is cleared programmatically, or when the selection is cleared by a different component. For more information about selection changes, use the 'selection-change' event emitted by the associated selection manager.
arcgisComplete
arcgisComplete: CustomEvent<SelectionToolbarViewModelEvents["complete"]> Fires when the selection operation is complete or canceled and results have been processed.
- Example
- const toolbar = document.querySelector("arcgis-selection-toolbar");toolbar.addEventListener("arcgisComplete", (event) => {const { aborted, selection, operationType, toolName } = event.detail;console.log("Selection complete:", {aborted,selection,operationType,toolName});});
arcgisPropertyChange
arcgisPropertyChange: CustomEvent<{ name: "activeOperation" | "state"; }> Emitted when the value of a property is changed. Use this to listen to changes to properties.
arcgisReady
arcgisReady: CustomEvent<void> Emitted when the component associated with a map or scene view is ready for user interaction.
arcgisSelectionChange
arcgisSelectionChange: CustomEvent<SelectionToolbarViewModelEvents["selection-change"]> Fires when the potential selection set changes while drawing. This event will not fire unless
the syncWhileDrawing property is set to true. For the final selection set, use the complete event
or refer to the associated selection manager.
- Example
- const toolbar = document.querySelector("arcgis-selection-toolbar");toolbar.addEventListener("arcgisSelectionChange", (event) => {const { added, removed, operationType } = event.detail;console.log("Selection changed:", {added,removed,operationType,});});