FeatureViewModel

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

Provides the logic for the Feature widget.

See also

Constructors

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
Abilities

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

more details
FeatureViewModel
Content[]|Widget|HTMLElement|String

The content of the feature.

more details
FeatureViewModel
String

The name of the class.

more details
Accessor
Boolean

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

more details
FeatureViewModel
Object

The formatted attributes calculated from fieldInfo PopupTemplate content.

more details
FeatureViewModel
Graphic

The Graphic used to represent the feature.

more details
FeatureViewModel
Object

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

more details
FeatureViewModel
Map

A reference to the view's Map.

more details
FeatureViewModel
SpatialReference

The spatial reference used for Arcade operations.

more details
FeatureViewModel
String

The view model's state.

more details
FeatureViewModel
String

The title for the feature.

more details
FeatureViewModel
MapView|SceneView

A reference to the MapView or SceneView.

more details
FeatureViewModel
Boolean

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

more details
FeatureViewModel

Property Details

abilities Abilitiesautocast
Since: ArcGIS API for JavaScript 4.21

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

The content of the feature.

Default Value:null
declaredClass Stringreadonly inherited

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

defaultPopupTemplateEnabled Boolean
Since: ArcGIS API 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 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 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 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"

map Map
Since: ArcGIS API for JavaScript 4.11

A reference to the view's Map. Use this property when needing to get access to the underlying layers within the map. This can then be used within Arcade expressions.

Default Value:null
See also
Example
// The building footprints repreent the buildings that intersect a clicked parcel
let buildingFootprints = Intersects($feature, FeatureSetByName($map, "Building Footprints"));
spatialReference SpatialReference
Since: ArcGIS API for JavaScript 4.11

The spatial reference used for Arcade operations.

Default Value:null
See also
state Stringreadonly
Since: ArcGIS API for JavaScript 4.21

The view model's state.

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

Default Value:disabled
title Stringreadonly

The title for the feature.

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

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.

more details
Accessor
Boolean

Returns true if a named group of handles exist.

more details
Accessor

Paginates to the next media info.

more details
FeatureViewModel

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

more details
FeatureViewModel

Removes a group of handles owned by the object.

more details
Accessor

Paginates to a specified media info object.

more details
FeatureViewModel

Method Details

addHandles(handleOrHandles, groupKey)inherited
Since: ArcGIS API for JavaScript 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 }
);

// Handle gets removed when the object is destroyed.
this.addHandles(handle);
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(groupKey){Boolean}inherited
Since: ArcGIS API for JavaScript 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(contentElementIndex)

Paginates to the next media info.

Parameter
contentElementIndex Number

The index position of the media content element.

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(groupKey)inherited
Since: ArcGIS API for JavaScript 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(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

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.