▾
import FeaturesModel from "@arcgis/core/popup/FeaturesModel.js";const FeaturesModel = await $arcgis.import("@arcgis/core/popup/FeaturesModel.js");- Inheritance
- FeaturesModel→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 5.2
Provides reactive state and behavior for the Features (Next) and Popup components, including fetching and paging popup features, tracking selection, and coordinating highlighting and actions.
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
| readonly | | |
| | ||
| | ||
| string | HTMLElement | null | undefined | | |
| readonly inherited | ||
| readonly | | |
| | ||
| readonly | | |
| readonly | | |
| readonly | | |
| | ||
| | ||
| Graphic[] | | |
| | ||
| inherited | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| readonly | | |
| readonly | | |
| | ||
| readonly | | |
| | ||
| readonly | | |
| readonly | | |
| | ||
| | ||
| | ||
| readonly | | |
| readonly | | |
| |
active
- Type
- boolean
Indicates if the features component is open and is not waiting for results.
- See also
aggregatedFeaturesEnabled
- Type
- boolean
Indicates if aggregated feature browsing is active in a
cluster or bin. This value becomes true when the user enables feature browsing with the "Browse features" action button in the aggregate popup template. This should only be set programmatically when the selectedFeature is an aggregate graphic.
- Default value
- false
content
- Type
- string | HTMLElement | null | undefined
The information to display. When this property is set, this content may only be 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 popup that will always be displayed// unless it is overridden by a PopupTemplate.features.content = "This is the content for the selected feature. It can be set to any string or HTML element.";
defaultActions
- Type
- Collection<PopupAction>
The default actions for the selected feature, or the default zoom action when no feature is selected.
defaultPopupTemplateEnabled
- Type
- boolean
Enables automatic creation of a popup template for layers that have popups enabled but no popupTemplate defined. Automatic popup templates are supported for layers that support the createPopupTemplate method. Supported for BuildingComponentSublayer, CatalogFootprintLayer, CSVLayer, FeatureLayer, GeoJSONLayer, ImageryLayer), ImageryTileLayer, KnowledgeGraphSublayer, OGCFeatureLayer, ParquetLayer, PointCloudLayer, SceneLayer, StreamLayer, Sublayer, SubtypeSublayer, VoxelLayer, WCSLayer, and WFSLayer.
- Default value
- false
diagnostics
- Type
- FetchPopupFeaturesDiagnostics | null | undefined
Diagnostics collected while fetching features from a view.
effectiveHeading
The heading currently displayed for the selected feature item.
This value resolves to the selected feature item's heading when available, otherwise it falls back to heading.
- See also
featureItemAbilities
- Type
- FeatureAbilities | null | undefined
Defines the specific FeatureAbilities that can be used when querying and displaying content.
featurePage
The number of feature batches prepared for browsing. Each batch contains up to featuresPerPage features. This value is null when there are no features.
Set this value to 1 to reset browsing, or increment it by one to prepare the next batch. Other assignments are ignored. Selecting a feature does not change this value; use selectedFeatureIndex to select any feature independently of browsing.
- Default value
- null
features
- Type
- Graphic[]
An array of features. 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 properties are 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 is set based on the value of the selected feature.
- 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}"});let g2 = new Graphic();g2.popupTemplate = new PopupTemplate({title: "Results title",content: "Results: {ATTRIBUTE_NAME}"});let g3 = new Graphic();g3.popupTemplate = new PopupTemplate({title: "Results title",content: "Results: {ATTRIBUTE_NAME}"});let g4 = new Graphic();g4.popupTemplate = new PopupTemplate({title: "Results title",content: "Results: {ATTRIBUTE_NAME}"});let g5 = new Graphic();g5.popupTemplate = new PopupTemplate({title: "Results title",content: "Results: {ATTRIBUTE_NAME}"});// Create an array of graphics and set this to the features property. The content and heading ofvwill 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];featuresModel.features = graphics;
goToOverride
- Type
- GoToOverride | null | undefined
- 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);};
heading
The heading. 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.
- Example
- // This heading will display in the popup unless a selected feature's// PopupTemplate overrides it.featureComponent.heading = "Population by zip codes in Southern California";
highlightEnabled
- Type
- boolean
Indicates whether to highlight the selected feature using one of the HighlightOptions defined in the view's View.highlights collection.
- Default value
- true
includeDefaultActions
- Type
- boolean
Indicates whether or not to include defaultActions.
In order to disable any default actions, it is necessary to set includeDefaultActions to false.
- Default value
- true
- Example
- // Removes the default actionsfeaturesModel.includeDefaultActions = false;
location
Geometry used to show the location of the feature. This is automatically set when selecting a feature. If displaying content not related to features in the map, such as the results from a task, then you must set this property before setting open to true.
- See also
- Examples
- // Sets the location to the center of the viewfeaturesModel.location = viewElement.center;featuresModel.open = true;// Display the featuresModel when and where the user clicks the view.reactiveUtils.on(()=>viewElement, "arcgisViewClick", ({ details: { mapPoint } })=>{featuresModel.location = mapPoint;featuresModel.open = true;});
map
A 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.
open
- Type
- boolean
Indicates whether the component is open. This property is true when querying for results, even if it is not open. Use the active property to check if the component is open and is not waiting for results.
- See also
- Default value
- false
selectedFeature
The selected feature accessed. The content is determined based on the PopupTemplate assigned to this feature.
spatialReference
- Type
- SpatialReference | null | undefined
The spatial reference used for Arcade operations. This property should be set if Arcade expressions are executed that contain geometry functions.
Alternatively, the view property can be used to provide the spatial reference instance for this property.
streamingFeatures
- Type
- boolean
Indicates whether features are being streamed into the collection.
timeZone
- Type
- TimeZone
Dates and times will be displayed in this time zone. By default this time zone is
inherited from the associated MapView or SceneView if the view property is set. When a view is not associated, then the property will fallback to the system time zone.
Possible Values
| Value | Description |
|---|---|
| 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. |
updateLocationEnabled
- Type
- boolean
Indicates whether to update the location when the selectedFeatureIndex changes.
- Default value
- false
view
- Type
- MapViewOrSceneView | null | undefined
A reference to the MapView or SceneView.
A view is required if the user expects it to display content in any of the following situations:
- 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). - Content is displayed from the popup template of an aggregate feature (i.e. a cluster or bin).
- Values from
dateandtimestamp-offsetfields should respect the associated MapView or SceneView.
waitingForContents
- Type
- boolean
Indicates whether content is being generated for any currently loaded feature models.
zoomFactor
- Type
- number
Number of levels of detail (LOD) to zoom in on the selected feature.
- Default value
- 4
- Example
- // Restricts the zooming to two LODS when the zoom in action is clicked.featuresModel.zoomFactor = 2;
Methods
| Method | Signature | Class |
|---|---|---|
| clear(): void | | |
| inherited | emit<Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean | |
| inherited | hasEventListener<Type extends EventNames<this>>(type: Type): boolean | |
| next(): void | | |
| inherited | on<Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle | |
| previous(): void | | |
| zoomTo(params: GoToParameters): Promise<void> | |
emit
- Signature
-
emit <Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
- Type parameters
- <Type extends EventNames<this>>
- 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.
hasEventListener
- Signature
-
hasEventListener <Type extends EventNames<this>>(type: Type): boolean
- Type parameters
- <Type extends EventNames<this>>
Indicates whether there is an event listener on the instance that matches the provided event name.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| type | Type | The name of the event. | |
- Returns
- boolean
Returns true if the class supports the input event.
next
- Signature
-
next (): void
Selects the feature at the next index in relation to the selected feature.
- See also
- Returns
- void
on
- Signature
-
on <Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
- Type parameters
- <Type extends EventNames<this>>
Registers an event handler on the instance. Call this method to hook an event with a listener.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| 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).Property Type Description remove Function When 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);});
previous
- Signature
-
previous (): void
Selects the feature at the previous index in relation to the selected feature.
- See also
- Returns
- void
zoomTo
- Signature
-
zoomTo (params: GoToParameters): Promise<void>
Sets the view to a given target. If goToOverride is set, goToOverride() will be called with the current view and specified params.
Otherwise, the view will be set using the provided params.
- See also
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| params | The parameters to pass to the | |
- Returns
- Promise<void>
A promise that resolves when the view's extent updates to the value defined in the GoToParameters.target.