Skip to content
import FeatureViewModel from "@arcgis/core/widgets/Feature/FeatureViewModel.js";
Inheritance:
FeatureViewModelAccessor
Since
ArcGIS Maps SDK for JavaScript 4.7

Provides the logic for the Feature widget and component.

See also

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.

abilities

Property
Type
Abilities
Since
ArcGIS Maps SDK for JavaScript 4.21

Defines the specific Abilities that the Feature and Popup widgets should use when querying and displaying its content.

content

readonly Property
Type
PopupViewModelContent | null | undefined

The PopupTemplate.content of the feature.

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor

The name of the class. The declared class name is formatted as esri.folder.className.

defaultPopupTemplateEnabled

Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.11

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 FeatureLayer, GeoJSONLayer, OGCFeatureLayer, SceneLayer, CSVLayer, PointCloudLayer, StreamLayer, and ImageryLayer).

Default value
false

formattedAttributes

readonly Property
Type
FeatureFormattedAttributes | null | undefined

The formatted attributes calculated from fieldInfo PopupTemplate content. They are obtained from the feature's graphic attribute values and can be read:

graphic

autocast Property
Type
Graphic | null | undefined

The Graphic used to represent the feature.

See also
Example
let graphic = new Graphic({
geometry: view.center,
attributes: {
"name": "Spruce",
"family": "Pinaceae",
"count": 126
},
symbol: new SimpleMarkerSymbol({
style: "square",
color: "blue",
size: "8px"
}),
popupTemplate: {
content: [
{
// Set popup template content
}
]
}
});

isFeatureFromTable

readonly Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.33

Indicates whether the current FeatureViewModel's graphic resides in a non-spatial table.

lastEditInfo

readonly Property
Type
LastEditInfo | null | undefined

A read-only property containing metadata regarding the last edit performed on a feature. This object has the following properties:

location

autocast Property
Type
Point | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.29

The Point representing the location of the MapView interaction used to trigger the opening of the widget.

This value should be set when executing Arcade expressions in the Feature widget that expect the $userInput profile variable to have a value.

See also
Example
view.on("click", (event) => {
const { mapPoint } = event;
feature.viewModel.location = mapPoint;
});

map

Property
Type
EsriMap | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.11

A map is required when the input graphic has 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.

See also
Example
// The building footprints represent the buildings that intersect a clicked parcel
let buildingFootprints = Intersects($feature, FeatureSetByName($map, "Building Footprints"));

relatedInfos

readonly Property
Type
Map<string, RelatedInfo>
Since
ArcGIS Maps SDK for JavaScript 4.34

A read-only map containing information about related features for the current feature. The keys are related layer IDs as strings, and the values are RelatedInfo objects. This property is populated when the feature has related fields and is used to manage and display related feature information in the widget.

spatialReference

autocast Property
Type
SpatialReference | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.11

The spatial reference used for Arcade operations. This property should be set if executing Arcade expressions that contain geometry functions.

See also

state

readonly Property
Type
State
Since
ArcGIS Maps SDK for JavaScript 4.21

The view model's state.

Default value
"disabled"

timeZone

autocast Property
Type
TimeZone
Since
ArcGIS Maps SDK for JavaScript 4.29

Dates and times displayed in the widget will be displayed in this time zone. By default this time zone is inherited from MapView.timeZone. When a MapView is not associated with the widget then the property will fallback to the system time zone.

Possible Values

ValueDescription
systemDates and times will be displayed in the timezone of the device or browser.
unknownDates and time are not adjusted for any timezone.
Specified IANA timezoneDates and times will be displayed in the specified IANA time zone. See wikipedia - List of tz database time zones.

title

readonly Property
Type
string

The title for the feature.

Default value
""

uid

readonlyinherited Property
Type
string
Inherited from: IdentifiableMixin
Since
ArcGIS Maps SDK for JavaScript 4.33

An automatically generated unique identifier assigned to the instance. The unique id is generated each time the application is loaded.

view

Property
Type
MapViewOrSceneView | null | undefined

A reference to the MapView or SceneView. Set this to link the widget to a specific view.

The FeatureViewModel requires a view if the user expects it to display content in any of the following situations:

waitingForContent

readonly Property
Type
boolean

Indicates whether the feature is currently waiting for all of its content to finish loading.

Methods

MethodSignatureClass
nextMedia(contentElementIndex: number): void
previousMedia(contentElementIndex: number): void
setActiveMedia(contentElementIndex: number, mediaInfoIndex: number): void
updateGeometry(): Promise<void>

nextMedia

Method
Signature
nextMedia (contentElementIndex: number): void

Paginates to the next media info.

Parameters
ParameterTypeDescriptionRequired
contentElementIndex

The index position of the media content element.

Returns
void

previousMedia

Method
Signature
previousMedia (contentElementIndex: number): void

Paginates to the previous media info in the specified media content element.

Parameters
ParameterTypeDescriptionRequired
contentElementIndex

The index position of the media content element.

Returns
void

setActiveMedia

Method
Signature
setActiveMedia (contentElementIndex: number, mediaInfoIndex: number): void

Paginates to a specified media info object. For example, you may have media content which contains multiple mediaInfos. This method allows you to specify the index of the mediaInfos you wish to display.

Prior to version 4.17, this method was named goToMedia.

Parameters
ParameterTypeDescriptionRequired
contentElementIndex

The index position of the media content element to be updated.

mediaInfoIndex

The index position of the media info object you wish to display.

Returns
void

updateGeometry

Method
Signature
updateGeometry (): Promise<void>
Since
ArcGIS Maps SDK for JavaScript 4.33

Fetches the geometry of the graphic if the geometry does not exist. This method can be called to ensure the graphic's geometry is available when the geometry is necessary to take action such as calling View2D.goTo() with the graphic as the target.

Returns
Promise<void>

A promise that resolves when the geometry has been updated.

Type definitions

PopupViewModelContent

Type definition