import FeatureVM from "@arcgis/core/widgets/Feature/FeatureViewModel.js";
const FeatureVM = await $arcgis.import("@arcgis/core/widgets/Feature/FeatureViewModel.js");
@arcgis/core/widgets/Feature/FeatureViewModel
- See also
-
Feature widget- Deprecated since 4.34. Use the Feature component instead.
- Popup
- PopupTemplate
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 | ||
Indicates whether the current FeatureViewModel's graphic resides in a non-spatial table. | 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 | ||
A read-only map containing information about related features for the current feature. | 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
-
The content of the feature.
- Default Value:null
-
defaultPopupTemplateEnabled
PropertydefaultPopupTemplateEnabled BooleanSince: 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
createPopupTemplatemethod. (Supported for FeatureLayer, GeoJSONLayer, OGCFeatureLayer, SceneLayer, CSVLayer, PointCloudLayer, StreamLayer, and ImageryLayer).- Default Value:false
-
The formatted attributes calculated from
fieldInfoPopupTemplate 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
-
optionalglobal Object
The formatted attributes specified at the root level of the PopupTemplate using the PopupTemplate.fieldInfos property.
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
-
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 } ] } });
-
A read-only property containing metadata regarding the last edit performed on a feature. This object has the following properties:
-
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
$userInputprofile variable to have a value.- Default Value:null
- See also
Exampleview.on("click", (event) => { const { mapPoint } = event; feature.viewModel.location = mapPoint; });
-
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
$mapprofile variable to access data from layers within a map. Without a map, expressions that use$mapwill 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"));
-
relatedInfos
PropertyrelatedInfos Map<string, RelatedInfo>readonlySince: ArcGIS Maps SDK for JavaScript 4.34FeatureViewModel since 4.7, relatedInfos added at 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
PropertyspatialReference SpatialReference |null |undefinedautocastSince: 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
Propertystate StringreadonlySince: 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
PropertytimeZone StringSince: 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
systemtime 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
Propertytitle 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
$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 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
PropertywaitingForContent 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 | ||
Promise<void> | Fetches the geometry of the graphic if the geometry does not exist. | 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 trueif 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");
-
Since: ArcGIS Maps SDK for JavaScript 4.33FeatureViewModel since 4.7, updateGeometry added at 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
goTo()with the graphic as thetarget.ReturnsType Description Promise<void> A promise that resolves when the geometry has been updated.
Type Definitions
-
Abilities
Type DefinitionAbilities Object -
- Properties
-
optionalattachmentsContent BooleanDefault Value:true
Indicate whether the widget should query and display attachments associated with the feature.
optionalchartAnimation BooleanDefault Value:trueIndicate whether the widget should display animations for charts residing in media content elements.
optionalcustomContent BooleanDefault Value:trueIndicate whether the widget should display any custom content elements.
optionalfieldsContent BooleanDefault Value:trueIndicate whether the widget should display any fields content elements.
optionalmediaContent BooleanDefault Value:trueIndicate whether the widget should display any media content elements.
optionalrelationshipContent BooleanDefault Value:trueIndicate whether the widget should display relationship content elements.
optionaltextContent BooleanDefault Value:trueIndicate whether the widget should display any text content elements.
optionalutilityNetworkAssociationsContent BooleanDefault Value:trueIndicate whether the widget should display utility network associations content elements.
-
LayerInfo
Type DefinitionLayerInfo Object -
Information about the layer associated with the feature.
-
RelatedInfo
Type DefinitionRelatedInfo Object -
Information about the features that are related to the current feature.
- Properties
-
url String
The URL of the related layer.
optionaloutStatistics StatisticDefinition[]An array of statistics to be calculated for the related features.
optional An array of related fields that are related to the current feature.
optional An array of features related to the current feature.
optional An array of related features with statistics for the current feature.
optionalrelation RelationshipThe relationship between the current feature and the related features.
optionallayerInfo LayerInfoThe layer information for the related features.
optionalsourceSpatialReference SpatialReferenceThe spatial reference of the source feature.