require(["esri/widgets/Feature/FeatureViewModel"], (FeatureVM) => { /* code goes here */ });
import FeatureVM from "@arcgis/core/widgets/Feature/FeatureViewModel.js";
esri/widgets/Feature/FeatureViewModel
Provides the logic for the Feature widget.
- See also
Constructors
-
Parameterproperties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
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 | 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 | 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 | ||
FeatureViewModel | |||
Indicates whether the feature is currently waiting for all of its content to finish loading. | FeatureViewModel |
Property Details
-
defaultPopupTemplateEnabled
defaultPopupTemplateEnabled Boolean
Since: ArcGIS Maps SDK for JavaScript 4.11FeatureViewModel 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 theshort-date-short-time
preset dateFormat rather thanlong-month-day-year
in default popup templates created by setting thedefaultPopupTemplateEnabled
property totrue
. 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
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
The formatted attributes specified at the root level of the PopupTemplate using the PopupTemplate.fieldInfos property.
content ObjectThe 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 Graphic
-
The Graphic used to represent the feature.
- Default Value:null
- See also
-
- PopupTemplate.content
Examplelet 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
lastEditInfo Objectreadonly
-
A read-only property containing metadata regarding the last edit performed on a feature. This object has the following properties:
-
location
location Point
Since: ArcGIS Maps SDK for JavaScript 4.29FeatureViewModel 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
Exampleview.on("click", (event) => { const { mapPoint } = event; feature.viewModel.location = mapPoint; });
-
map
map Map
Since: ArcGIS Maps SDK for JavaScript 4.11FeatureViewModel 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
spatialReference SpatialReference
Since: ArcGIS Maps SDK for JavaScript 4.11FeatureViewModel 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
state Stringreadonly
Since: ArcGIS Maps SDK for JavaScript 4.21FeatureViewModel since 4.7, state added at 4.21. -
The view model's state.
Possible Values:"ready" |"disabled" |"error" |"loading"
- Default Value:"disabled"
-
timeZone
timeZone String
Since: ArcGIS Maps SDK for JavaScript 4.29FeatureViewModel 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
title Stringreadonly
-
The title for the feature.
-
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:
- The graphic has a popupTemplate containing Arcade expressions in ExpressionInfo or ExpressionContent that may use geometry functions or reference the
$map
profile 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
date
andtimestamp-offset
fields should respect the view's time zone.
- The graphic has a popupTemplate containing Arcade expressions in ExpressionInfo or ExpressionContent that may use geometry functions or reference the
-
waitingForContent
waitingForContent Booleanreadonly
-
Indicates whether the feature is currently waiting for all of its content to finish loading.
Method Overview
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
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor 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();
ParametershandleOrHandles WatchHandle|WatchHandle[]Handles marked for removal once the object is destroyed.
groupKey *optionalKey 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
InheritedMethodhasHandles(groupKey){Boolean}
Inherited from AccessorSince: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, hasHandles added at 4.25. -
Returns true if a named group of handles exist.
ParametergroupKey *optionalA group key.
ReturnsType 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"); }
-
Paginates to the next media info.
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, removeHandles added at 4.25. -
Removes a group of handles owned by the object.
ParametergroupKey *optionalA group key or an array or collection of group keys to remove.
Exampleobj.removeHandles(); // removes handles from default group obj.removeHandles("handle-group"); obj.removeHandles("other-handle-group");
Type Definitions
-
- Properties
-
attachmentsContent Boolean
Indicate whether the widget should query and display attachments associated with the feature. Default value is
true
.chartAnimation BooleanIndicate whether the widget should display animations for charts residing in media content elements. Default value is
true
.customContent BooleanIndicate whether the widget should display any custom content elements. Default value is
true
.fieldsContent BooleanIndicate whether the widget should display any fields content elements. Default value is
true
.mediaContent BooleanIndicate whether the widget should display any media content elements. Default value is
true
.textContent BooleanIndicate whether the widget should display any text content elements. Default value is
true
.