FeatureViewModel

AMD: require(["esri/widgets/Feature/FeatureViewModel"], (FeatureVM) => { /* code goes here */ });
ESM: import FeatureVM from "@arcgis/core/widgets/Feature/FeatureViewModel.js";
Class: esri/widgets/Feature/FeatureViewModel
Inheritance: FeatureViewModel Accessor
Since: ArcGIS Maps SDK for JavaScript 4.7

Provides the logic for the Feature widget.

See also

Constructors

FeatureViewModel

Constructor
new FeatureViewModel(properties)
Parameter
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
Show inherited properties Hide inherited properties
Name Type Summary Class

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

FeatureViewModel

The content of the feature.

FeatureViewModel

The name of the class.

Accessor

Enables automatic creation of a popup template for layers that have popups enabled but no popupTemplate defined.

FeatureViewModel

The formatted attributes calculated from fieldInfo PopupTemplate content.

FeatureViewModel

The Graphic used to represent the feature.

FeatureViewModel

A read-only property containing metadata regarding the last edit performed on a feature.

FeatureViewModel

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

FeatureViewModel

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.

FeatureViewModel

The spatial reference used for Arcade operations.

FeatureViewModel

The view model's state.

FeatureViewModel

Dates and times displayed in the widget will be displayed in this time zone.

FeatureViewModel

The title for the feature.

FeatureViewModel

A reference to the MapView or SceneView.

FeatureViewModel

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

FeatureViewModel

Property Details

abilities

Property
abilities Abilitiesautocast
Since: ArcGIS Maps SDK for JavaScript 4.21 FeatureViewModel since 4.7, abilities added at 4.21.

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

content

Property
content Content[] |Widget |HTMLElement |Stringreadonly

The content of the feature.

Default Value:null

declaredClass

Inherited
Property
declaredClass Stringreadonly
Inherited from Accessor

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

defaultPopupTemplateEnabled

Property
defaultPopupTemplateEnabled Boolean
Since: ArcGIS Maps SDK for JavaScript 4.11 FeatureViewModel since 4.7, defaultPopupTemplateEnabled added at 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).

Starting with version 4.28, date fields are formatted using the short-date-short-time preset dateFormat rather than long-month-day-year in default popup templates created by setting the defaultPopupTemplateEnabled property to true. For example, previously a date that may have appeared as "December 30, 1997" will now appear as "12/30/1997 6:00 PM".

Default Value:false

formattedAttributes

Property
formattedAttributes Objectreadonly

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

  • globally using the fieldInfos property directly at the root level of the PopupTemplate, or
  • per an individual content element. This element is defined with a fieldsContent popup element set on the PopupTemplate content property.
Properties
global Object
optional

The formatted attributes specified at the root level of the PopupTemplate using the PopupTemplate.fieldInfos property.

content Object
optional

The formatted attributes for an individual content element. This is derived from the esri/PopupTemplate PopupTemplate, or per an individual content element. This element is defined with a fieldsContent popup element set on the PopupTemplate's content.

Default Value:null

graphic

Property
graphic Graphic

The Graphic used to represent the feature.

Default Value:null
See also
  • PopupTemplate.content
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
      }
    ]
  }
});

lastEditInfo

Property
lastEditInfo Objectreadonly

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

Properties
user String

User who performed the last edit on a feature.

date String

Date that the edit was performed.

type String

The type of edit that was performed on the feature.

Possible Values:"edit"|"create"

location

Property
location Point
Since: ArcGIS Maps SDK for JavaScript 4.29 FeatureViewModel since 4.7, location added at 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.

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

map

Property
map Map
Since: ArcGIS Maps SDK for JavaScript 4.11 FeatureViewModel since 4.7, map added at 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.

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

spatialReference

Property
spatialReference SpatialReference
Since: ArcGIS Maps SDK for JavaScript 4.11 FeatureViewModel since 4.7, spatialReference added at 4.11.

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

Default Value:null
See also

state

Property
state Stringreadonly
Since: ArcGIS Maps SDK for JavaScript 4.21 FeatureViewModel since 4.7, state added at 4.21.

The view model's state.

Possible Values:"ready" |"disabled" |"error" |"loading"

Default Value:disabled

timeZone

Property
timeZone String
Since: ArcGIS Maps SDK for JavaScript 4.29 FeatureViewModel since 4.7, timeZone added at 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

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.

title

Property
title Stringreadonly

The title for the feature.

view

Property
view MapView |SceneView

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

Property
waitingForContent Booleanreadonly

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

Method Overview

Show inherited methods Hide inherited methods
Name Return Type Summary Class

Adds one or more handles which are to be tied to the lifecycle of the object.

Accessor

Returns true if a named group of handles exist.

Accessor

Paginates to the next media info.

FeatureViewModel

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

FeatureViewModel

Removes a group of handles owned by the object.

Accessor

Paginates to a specified media info object.

FeatureViewModel

Method Details

addHandles

Inherited
Method
addHandles(handleOrHandles, groupKey)
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, addHandles added at 4.25.

Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.

// Manually manage handles
const handle = reactiveUtils.when(
  () => !view.updating,
  () => {
    wkidSelect.disabled = false;
  },
  { once: true }
);

this.addHandles(handle);

// Destroy the object
this.destroy();
Parameters
handleOrHandles WatchHandle|WatchHandle[]

Handles marked for removal once the object is destroyed.

groupKey *
optional

Key identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.

hasHandles

Inherited
Method
hasHandles(groupKey){Boolean}
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, hasHandles added at 4.25.

Returns true if a named group of handles exist.

Parameter
groupKey *
optional

A group key.

Returns
Type Description
Boolean Returns true if a named group of handles exist.
Example
// Remove a named group of handles if they exist.
if (obj.hasHandles("watch-view-updates")) {
  obj.removeHandles("watch-view-updates");
}

nextMedia

Method
nextMedia(contentElementIndex)

Paginates to the next media info.

Parameter
contentElementIndex Number

The index position of the media content element.

previousMedia

Method
previousMedia(contentElementIndex)

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

Parameter
contentElementIndex Number

The index position of the media content element.

removeHandles

Inherited
Method
removeHandles(groupKey)
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, removeHandles added at 4.25.

Removes a group of handles owned by the object.

Parameter
groupKey *
optional

A group key or an array or collection of group keys to remove.

Example
obj.removeHandles(); // removes handles from default group

obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");

setActiveMedia

Method
setActiveMedia(contentElementIndex, mediaInfoIndex)

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
contentElementIndex Number

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

mediaInfoIndex Number

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

Type Definitions

Abilities

Type Definition
Abilities

This object defines specific abilities for the Feature and Popup widgets.

Properties
attachmentsContent Boolean
optional

Indicate whether the widget should query and display attachments associated with the feature. Default value is true.

chartAnimation Boolean
optional

Indicate whether the widget should display animations for charts residing in media content elements. Default value is true.

customContent Boolean
optional

Indicate whether the widget should display any custom content elements. Default value is true.

fieldsContent Boolean
optional

Indicate whether the widget should display any fields content elements. Default value is true.

mediaContent Boolean
optional

Indicate whether the widget should display any media content elements. Default value is true.

textContent Boolean
optional

Indicate whether the widget should display any text content elements. Default value is true.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.