import "@arcgis/map-components/components/arcgis-features";The Features component allows users to view a feature's popupTemplate content such as attributes, actions, related records, etc., without having to be tied to a arcgis-map or arcgis-scene component. This component looks and behaves similarly to the arcgis-popup component, however unlike Popup, the Features component can be placed outside of the map or scene component. For example, when features are selected in the arcgis-map, the arcgis-popup opens within the map whether it is docked or anchored to the selected feature. With the Features component, the same information that Popup provides is shown in a separate container from the map, such as a HTML div within a Calcite Design System Shell Panel.
If multiple features are passed into the Features component, the component provides buttons to page though the features and a feature menu that allows the list of features to be displayed so the user can choose which feature content to display in the component. The component also respects feature reduction PopupTemplates for binning and clustering.
The Features component should be used if needing to use the Popup functionality outside of the map or scene component. If wanting to show a single feature's content without actions, related records, clustering configuration, etc., then use the arcgis-feature component.
- See also
Demo
Properties
| Property | Attribute | Type |
|---|---|---|
actions | | Collection<ActionButton | ActionToggle> |
activereadonly | | boolean |
autoDestroyDisabled | auto-destroy-disabled | boolean |
closeddeprecated | closed | boolean |
collapsed | collapsed | boolean |
content | content | HTMLElement | Widget | string |
defaultPopupTemplateEnabled | default-popup-template-enabled | boolean |
featureCountreadonly | | number |
featureMenuOpen | feature-menu-open | boolean |
featureMenuTitle | feature-menu-title | string |
featureNavigationTop | feature-navigation-top | boolean |
features | | Array<Graphic> |
featuresPerPage | features-per-page | number |
featuresTitledeprecated | features-title | string |
featureViewModelAbilities | | Abilities |
goToOverride | | (((view: MapView | SceneView, goToParameters: GoToParameters) => void)) |
headerActions | | Collection<ActionButton | ActionToggle> |
heading | heading | string |
headingLevel | heading-level | 1 | 2 | 3 | 4 | 5 | 6 |
hideActionBar | hide-action-bar | boolean |
hideCloseButton | hide-close-button | boolean |
hideFeatureListLayerTitle | hide-feature-list-layer-title | boolean |
hideFeatureMenuHeading | hide-feature-menu-heading | boolean |
hideFeatureNavigation | hide-feature-navigation | boolean |
hideFlow | hide-flow | boolean |
hideHeading | hide-heading | boolean |
hideSpinner | hide-spinner | boolean |
highlightDisabled | highlight-disabled | boolean |
icon | icon | string |
includeDefaultActionsDisabled | include-default-actions-disabled | boolean |
initialDisplayMode | initial-display-mode | "feature" | "list" |
label | label | string |
map | | Map |
messageOverrides | | Record<string, unknown> |
positiondeprecated | position | "bottom-leading" | "bottom-left" | "bottom-right" | "bottom-trailing" | "manual" | "top-leading" | "top-left" | "top-right" | "top-trailing" |
promises | | Array<Promise<Array<Graphic>>> |
referenceElement | reference-element | HTMLArcgisLinkChartElement | HTMLArcgisMapElement | HTMLArcgisSceneElement | string |
selectedDrillInFeaturereadonly | | Graphic |
selectedFeaturereadonly | | Graphic |
selectedFeatureComponentreadonly | | HTMLArcgisFeatureElement |
selectedFeatureIndex | selected-feature-index | number |
showCollapseButton | show-collapse-button | boolean |
spatialReference | | SpatialReference |
statereadonlyreflected | state | "disabled" | "ready" |
timeZone | time-zone | string |
view | | MapView | SceneView |
viewModel | | FeaturesViewModel |
visible | visible | boolean |
actions
actions: Collection<ActionButton | ActionToggle>Collection of action or action toggle objects displayed in the action bar.
Each action may be executed by clicking the icon or image symbolizing them.
By default, every component has a Zoom To action styled with a magnifying glass icon.
When this icon is clicked, the map zooms in four LODs and centers on the selected feature.
This default action can be removed by setting includeDefaultActionsDisabled to true, or by setting the overwriteActions property to true in the PopupTemplate.
The order of each action is the order in which they appear in the actions Collection.
The arcgisTriggerAction event fires each time an action is clicked.
Actions are defined with the properties listed in the ActionButton or ActionToggle class.
- See also
Example
// Defines an action button to zoom out from the selected feature
const zoomOutAction = {
type: "button",
// This text is displayed as a tooltip
title: "Zoom out",
// The ID by which to reference the action in the event handler
id: "zoom-out",
// Sets the icon used to style the action button
icon: "magnifying-glass-minus"
};
// Adds the custom action to the Features component's actions collection.
featuresComponent.actions.push(zoomOutAction);active
active: booleanIndicates if the component is active when it is visible and is not waiting for results.
- Default value
- false
autoDestroyDisabled
autoDestroyDisabled: booleanIf 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
closed
closed: booleanvisible instead.Indicates whether a component is closed. When true, the component will be hidden.
- Attribute
- closed
- Default value
- false
collapsed
collapsed: booleanIndicates whether the component displays its content. If true, only the header displays.
This property is only honored if showCollapsed is true.
- Attribute
- collapsed
- Default value
- false
content
content: HTMLElement | Widget | stringThe content of the Features component. When set directly on the component, this content is static and cannot use fields to set content templates. To set a template for the content based on field or attribute names, see PopupTemplate.content.
Example
// This sets generic instructions in the component that will always be displayed
// unless it is overridden by a PopupTemplate.
featuresComponent.content = "Click a feature on the map to view its attributes";- Attribute
- content
defaultPopupTemplateEnabled
defaultPopupTemplateEnabled: booleanEnables automatic creation of a popup template for layers that have popups enabled but no popupTemplate defined.
- Attribute
- default-popup-template-enabled
- Default value
- false
featureCount
featureCount: numberThe number of selected features available to the popup.
- Default value
- 0
featureMenuOpen
featureMenuOpen: booleanThis property enables multiple features in the component to display in a list rather than displaying the first selected feature.
Setting this to true allows the user to scroll through the list of features.
This value will only be honored if initialDisplayMode is set to "feature".
- Attribute
- feature-menu-open
- Default value
- false
featureMenuTitle
featureMenuTitle: stringSets the title to display on the component while viewing the feature menu.
- Attribute
- feature-menu-title
featureNavigationTop
featureNavigationTop: booleanIndicates whether the feature navigation arrows are displayed at the top of the component. By default, the navigation arrows are displayed at the bottom of the component.
- Attribute
- feature-navigation-top
- Default value
- false
features
features: Array<Graphic>An array of features associated with the Features component. Each graphic in this array must
have a valid PopupTemplate set. They may share the same
PopupTemplate or have unique
PopupTemplates depending on their attributes.
The content and heading
of the component is set based on the content and title properties of each graphic's respective
PopupTemplate.
When more than one graphic exists in this array, the current content of the component is set based on the value of the selected feature.
This value is null if no features are associated with the component.
Example
// When setting the features property, the graphics pushed to this property
// must have a PopupTemplate set.
let g1 = new Graphic();
g1.popupTemplate = new PopupTemplate({
title: "Results title",
content: "Results: {ATTRIBUTE_NAME}"
});
// Set the graphics as an array to the Features component instance. The content and title of
// the component will be set depending on the PopupTemplate of the graphics.
// Each graphic may share the same PopupTemplate or have a unique PopupTemplate
let graphics = [g1, g2, g3, g4, g5];
featuresComponent.features = graphics;featuresPerPage
featuresPerPage: numberThe number of features to fetch at one time.
- Attribute
- features-per-page
- Default value
- 20
featuresTitle
featuresTitle: stringheading instead.The title of the Features component.
- Attribute
- features-title
featureViewModelAbilities
featureViewModelAbilities: AbilitiesDefines the specific abilities that can be used when querying and displaying content.
goToOverride
goToOverride: (((view: MapView | SceneView, goToParameters: GoToParameters) => void))This function provides the ability to override either the arcgis-map.goTo or arcgis-scene.goTo methods.
Example
features.goToOverride = (map, goToParams)=> {
goToParams.options = {
duration: updatedDuration
};
return map.goTo(goToParams.target, goToParams.options);
};headerActions
headerActions: Collection<ActionButton | ActionToggle>The actions that are displayed in the header of the component.
heading
heading: stringThe title of the Features component. This can be set to any string value no matter the features that are selected. If the selected feature has a PopupTemplate, then the title set in the corresponding template is used here.
- See also
Example
// This title will display in the component unless a selected feature's
// PopupTemplate overrides it.
featuresComponent.title = "Population by zip codes in Southern California";- Attribute
- heading
headingLevel
headingLevel: 1 | 2 | 3 | 4 | 5 | 6Indicates the heading level to use for the heading of the component.
By default, the heading is rendered
as a level 2 heading (e.g. <h2>Popup title</h2>). Depending on the component's placement
in your app, you may need to adjust this heading for proper semantics. This is
important for meeting accessibility standards.
- Attribute
- heading-level
- Default value
- 2
hideActionBar
hideActionBar: booleanIndicates whether to hide the action bar that holds the feature's actions.
- Attribute
- hide-action-bar
- Default value
- false
hideCloseButton
hideCloseButton: booleanIndicates whether to hide the close button in the component.
- Attribute
- hide-close-button
- Default value
- false
hideFeatureListLayerTitle
hideFeatureListLayerTitle: booleanIndicates whether to hide the group heading for a list of multiple features.
- Attribute
- hide-feature-list-layer-title
- Default value
- false
hideFeatureMenuHeading
hideFeatureMenuHeading: booleanIndicates whether to hide the feature menu heading and description in the component's feature menu list.
- Attribute
- hide-feature-menu-heading
- Default value
- false
hideFeatureNavigation
hideFeatureNavigation: booleanIndicates whether to hide the feature pagination in the component. This allows the user to scroll through various selected features using pagination arrows.
- Attribute
- hide-feature-navigation
- Default value
- false
hideFlow
hideFlow: booleanDetermines whether the component should be shown within its built-in flow component or if the flow component should be excluded.
The component will be displayed within its original flow component if set to false.
The flow component will be omitted from the component if set to true.
To place the component into an existing Calcite flow component, set this property to false.
- Attribute
- hide-flow
- Default value
- false
hideHeading
hideHeading: booleanIndicates whether to hide the component's heading.
- Attribute
- hide-heading
- Default value
- false
hideSpinner
hideSpinner: booleanIndicates whether to hide the component's loading spinner.
- Attribute
- hide-spinner
- Default value
- false
highlightDisabled
highlightDisabled: booleanIndicates whether to highlight the selected feature in the associated arcgis-map or arcgis-scene component.
- Attribute
- highlight-disabled
- Default value
- false
icon
icon: stringIcon which represents the component. Typically used when the component is controlled by another component (e.g. by the Expand component).
- See also
- Attribute
- icon
includeDefaultActionsDisabled
includeDefaultActionsDisabled: booleanIndicates whether to include the default actions in the component.
In order to disable any default actions, it is necessary to set includeDefaultActionsDisabled to true.
- Attribute
- include-default-actions-disabled
- Default value
- false
initialDisplayMode
initialDisplayMode: "feature" | "list"Indicates whether to initially display a list of features, or the content for one feature.
- Attribute
- initial-display-mode
- Default value
- "feature"
map
map: MapA map is required when the input features have a popupTemplate that contains Arcade expressions in ExpressionInfo or ExpressionContent that may use the $map profile variable to access data from layers within a map. Without a map, expressions that use $map will throw an error.
Alternatively, the view property can be used to provide the map instance for this property.
Example
// The building footprints represent the buildings that intersect a clicked parcel
let buildingFootprints = Intersects($feature, FeatureSetByName($map, "Building Footprints"));- Default value
- null
messageOverrides
messageOverrides: Record<string, unknown>Replace localized message strings with your own strings.
Note: Individual message keys may change between releases.
position
position: "bottom-leading" | "bottom-left" | "bottom-right" | "bottom-trailing" | "manual" | "top-leading" | "top-left" | "top-right" | "top-trailing"slot instead.- Attribute
- position
promises
promises: Array<Promise<Array<Graphic>>>An array of pending Promises that have not yet been fulfilled. If there are
no pending promises, the value is null. When the pending promises are
resolved they are removed from this array and the features they return
are pushed into the features array.
referenceElement
referenceElement: HTMLArcgisLinkChartElement | HTMLArcgisMapElement | HTMLArcgisSceneElement | stringBy 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
selectedDrillInFeature
selectedDrillInFeature: GraphicThe feature that the component has drilled into. This feature is either associated with the selected feature in a relationship or utility network element.
selectedFeature
selectedFeature: GraphicThe selected feature accessed by the Features component. The content displayed in the component is determined based on the PopupTemplate assigned to this feature.
selectedFeatureComponent
selectedFeatureComponent: HTMLArcgisFeatureElementReturns a reference to the current arcgis-feature component. This is useful if needing to get a reference to the Feature component in order to make any changes to it.
selectedFeatureIndex
selectedFeatureIndex: numberIndex of the feature that is selected. When features are set, the first index is automatically selected.
- Attribute
- selected-feature-index
showCollapseButton
showCollapseButton: booleanIndicates whether to show the collapse button in the component.
- Attribute
- show-collapse-button
- Default value
- false
spatialReference
spatialReference: SpatialReferenceThe spatial reference used for Arcade operations. This property should be set if the Features component executes Arcade expressions that contain geometry functions.
Alternatively, the view property can be used to provide the spatial reference instance for this property.
- Default value
- null
state
state: "disabled" | "ready"The current state of the component.
- Attribute
- state
- Default value
- "disabled"
timeZone
timeZone: stringDates and times displayed in the component will be displayed in this time zone. By default this time zone is
inherited from arcgis-map.timeZone if the view property is set. When a MapView is not associated with the component
then the property will fallback to the system time zone.
Possible Values
system: Dates and times will be displayed in the timezone of the device or browser.unknown: Dates and time are not adjusted for any timezone.Specified IANA timezone: Dates and times will be displayed in the specified IANA time zone. See wikipedia - List of tz database time zones.
- Attribute
- time-zone
view
A reference to the MapView or SceneView.
The Features component requires a view to be set if:
- The features have a popupTemplate containing Arcade expressions in ExpressionInfo or ExpressionContent that may use geometry functions or reference the
$mapprofile variable (i.e. access data from layers within a map). Alternatively, set themapproperty. - Content is displayed from the popup template of an aggregate feature (i.e. a cluster or bin).
- Values from
dateandtimestamp-offsetfields should respect the view's time zone. Alternatively, set thetimeZoneproperty. - Using the fetchFeatures method or the
fetchFeaturesoption in theopenmethod. - Using the
Zoom todefault action. If theviewis not specified, set the includeDefaultActionsDisabled property totrueto remove this default action.
viewModel
viewModel: FeaturesViewModelvisible
visible: booleanIndicates whether the popup is visible. This property is true when the popup is querying for results, even if it is not open in the view.
Use the property to check if the component is visible.
- Attribute
- visible
- Default value
- false
Methods
| Method | Signature |
|---|---|
clear | clear(): Promise<void> |
close | close(): Promise<void> |
componentOnReady | componentOnReady(): Promise<void> |
destroy | destroy(): Promise<void> |
fetchFeatures | fetchFeatures(screenPoint: __esri.ScreenPoint, options?: __esri.FetchFeaturesOptions): Promise<__esri.FetchPopupFeaturesResult> |
next | next(): Promise<FeaturesViewModel> |
open | open(options?: __esri.FeaturesViewModelOpenOptions): Promise<void> |
previous | previous(): Promise<FeaturesViewModel> |
setFocus | setFocus(): Promise<void> |
triggerAction | triggerAction(action: __esri.ActionButton | __esri.ActionToggle): Promise<void> |
clear
clear(): Promise<void>Removes promises, features, content, and heading from the Features component.
- Returns
- Promise<void>
componentOnReady
componentOnReady(): Promise<void>Create a promise that resolves once component is fully loaded.
Example
const arcgisFeatures = document.querySelector("arcgis-features");
document.body.append(arcgisFeatures);
await arcgisFeatures.componentOnReady();
console.log("arcgis-features is ready to go!");- Returns
- Promise<void>
fetchFeatures
fetchFeatures(screenPoint: __esri.ScreenPoint, options?: __esri.FetchFeaturesOptions): Promise<__esri.FetchPopupFeaturesResult>Use this method to return feature(s) at a given screen location. These features are fetched from all of the layer in the view. In order to use this, a layer must already have an associated PopupTemplate. This method allows a developer to control how the input location is handled.
Example
// Use reactiveUtils to watch the map's click event.
reactiveUtils.on(() => map, "arcgisViewClick",
(event) => {
// Call fetchFeatures and pass in the click event screenPoint
featuresComponent.fetchFeatures(event.screenPoint).then((response) => {
// Access the response from fetchFeatures
response.allGraphicsPromise.then((graphics) => {
// If there are no graphics in the click event, then make sure
// the Features component is not showing.
if(graphics.length === 0){
featuresComponent.visible = false;
}
// If graphics do exist, set the Features component features property to the returned
// graphics from fetchFeatures.
else{
featuresComponent.features = graphics;
}
});
});Parameters
| Parameter | Type | Optional? |
|---|---|---|
| screenPoint | ScreenPoint | |
| options | FetchFeaturesOptions | undefined |
- Returns
- Promise<FetchPopupFeaturesResult>
next
next(): Promise<FeaturesViewModel>Selects the feature at the next index in relation to the selected feature.
- See also
- Returns
- Promise<FeaturesViewModel>
open
open(options?: __esri.FeaturesViewModelOpenOptions): Promise<void>Opens the Features component with content defined either explicitly with content
or driven from the PopupTemplate of input features.
Examples
// Use reactiveUtils to watch the map component's click event.
reactiveUtils.on(() => viewElement, "arcgisViewClick", (event) => {
const { mapPoint } = event.detail;
featuresComponent.open({
// Title and content displayed in the component
title: `Click location: (${mapPoint.x},${mapPoint.y})`,
content: "This is the default content displayed on click."
});
});// The Features component must have a reference element set on the component along with the
// location property to fetch features.
// Use reactiveUtils to watch the map component's click event.
reactiveUtils.on(() => viewElement, "arcgisViewClick", (event) => {
const { mapPoint } = event.detail;
featuresComponent.open({
location: mapPoint,
// Display the content for the selected feature(s) if a popupTemplate is defined.
fetchFeatures: true
});
});// Open the Features component with a specified array of graphics that already
// have a PopupTemplate set and display the feature menu when it opens.
featuresComponent.open({
// array of graphics
features: graphics,
// selected features initially display in a list
featureMenuOpen: true
});Parameters
| Parameter | Type | Optional? |
|---|---|---|
| options | FeaturesViewModelOpenOptions | undefined |
- Returns
- Promise<void>
previous
previous(): Promise<FeaturesViewModel>Selects the feature at the previous index in relation to the selected feature.
- See also
- Returns
- Promise<FeaturesViewModel>
setFocus
setFocus(): Promise<void>Use this method to give focus to the Component if the component is able to be focused.
- Returns
- Promise<void>
triggerAction
triggerAction(action: __esri.ActionButton | __esri.ActionToggle): Promise<void>Triggers the arcgisTriggerAction event and executes the action
at the specified index in the actions array.
Parameters
| Parameter | Type | Optional? |
|---|---|---|
| action | ActionButton | ActionToggle |
- Returns
- Promise<void>
Events
| Event | Type |
|---|---|
arcgisClose | CustomEvent<void> |
arcgisPropertyChange | CustomEvent<{ name: "state" | "active" | "collapsed" | "featureCount" | "visible" | "selectedFeature" | "featureMenuOpen" | "features" | "promises" | "selectedFeatureIndex" | "selectedDrillInFeature" | "selectedFeatureComponent"; }> |
arcgisReady | CustomEvent<void> |
arcgisTriggerAction | CustomEvent<FeaturesViewModelTriggerActionEvent> |
arcgisClose
arcgisClose: CustomEvent<void>Emitted when the component's close button is clicked.
arcgisPropertyChange
arcgisPropertyChange: CustomEvent<{ name: "state" | "active" | "collapsed" | "featureCount" | "visible" | "selectedFeature" | "featureMenuOpen" | "features" | "promises" | "selectedFeatureIndex" | "selectedDrillInFeature" | "selectedFeatureComponent"; }>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 to be interacted with.
arcgisTriggerAction
arcgisTriggerAction: CustomEvent<FeaturesViewModelTriggerActionEvent>Fires after the user clicks on an action in the Features component. This event may be used to define a custom function to execute when particular actions are clicked.
Example
viewElement.addEventListener("arcgisViewClick", (event) => {
const { mapPoint } = event.detail;
featuresComponent.open({
location: mapPoint,
fetchFeatures: true,
actions: [{
// This text is displayed as a tooltip
title: "Zoom out",
// The ID used to reference this action in the event handler
id: "zoom-out",
// Sets the icon font used to style the action button
icon: "magnifying-glass-minus"
},
{
title: "Delete Feature",
id: "delete-feature-action",
icon: "trash"
}]
});
});
// Fires each time an action is clicked
reactiveUtils.on(()=> featuresComponent, "arcgisTriggerAction", (event)=>{
// If the zoom-out action is clicked, execute the following code
if(event.detail.action.id === "zoom-out"){
// Zoom out two levels (LODs)
viewElement.goTo({
center: viewElement.center,
zoom: viewElement.zoom - 2
});
}
});