import FeatureViewModel from "@arcgis/core/widgets/Feature/FeatureViewModel.js";const FeatureViewModel = await $arcgis.import("@arcgis/core/widgets/Feature/FeatureViewModel.js");- Inheritance:
- FeatureViewModel→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 4.7
Provides the logic for the Feature widget and component.
- See also
Feature widget- Deprecated since 4.34. Use the Feature component instead.
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
| | ||
content readonly | | |
declaredClass readonly inherited | ||
| | ||
formattedAttributes readonly | | |
| | ||
isFeatureFromTable readonly | | |
lastEditInfo readonly | | |
| | ||
| | ||
relatedInfos readonly | | |
| | ||
state readonly | | |
| | ||
title readonly | | |
uid readonly inherited | ||
| | ||
waitingForContent readonly | |
content
- Type
- PopupViewModelContent | null | undefined
The PopupTemplate.content of the feature.
defaultPopupTemplateEnabled
- 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
- 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:
- globally using the PopupTemplate.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 PopupTemplate.content property.
graphic
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 } ] }}); lastEditInfo
- 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
- 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.
Example
view.on("click", (event) => { const { mapPoint } = event; feature.viewModel.location = mapPoint;}); map
- 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.
Example
// The building footprints represent the buildings that intersect a clicked parcellet buildingFootprints = Intersects($feature, FeatureSetByName($map, "Building Footprints")); relatedInfos
- 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
- 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.
state
- Type
- State
- Since
- ArcGIS Maps SDK for JavaScript 4.21
The view model's state.
- Default value
- "disabled"
timeZone
- 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
| 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. |
uid
- Type
- string
- 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
- 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:
- 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.
waitingForContent
- Type
- boolean
Indicates whether the feature is currently waiting for all of its content to finish loading.
Methods
| Method | Signature | Class |
|---|---|---|
nextMedia(contentElementIndex: number): void | | |
previousMedia(contentElementIndex: number): void | | |
setActiveMedia(contentElementIndex: number, mediaInfoIndex: number): void | | |
updateGeometry(): Promise<void> | |
setActiveMedia
- Signature
-
setActiveMedia (contentElementIndex: number, mediaInfoIndex: number): void
updateGeometry
- 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.
Type definitions
PopupViewModelContent
- Type
- Content[] | string | HTMLElement | Widget