UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

733 lines (730 loc) • 46.7 kB
import type Graphic from "../../Graphic.js"; import type EsriMap from "../../Map.js"; import type Collection from "../../core/Collection.js"; import type Point from "../../geometry/Point.js"; import type SpatialReference from "../../geometry/SpatialReference.js"; import type Widget from "../Widget.js"; import type FeatureViewModel from "../Feature/FeatureViewModel.js"; import type { EventedAccessor } from "../../core/Evented.js"; import type { ScreenPoint } from "../../core/types.js"; import type { SpatialReferenceProperties } from "../../geometry/SpatialReference.js"; import type { TimeZone } from "../../time/types.js"; import type { MapViewOrSceneView } from "../../views/MapViewOrSceneView.js"; import type { FetchPopupFeaturesResult } from "../../views/types.js"; import type { Abilities as FeatureViewModelAbilities } from "../Feature/types.js"; import type { PopupOpenOptions, State, FetchFeaturesOptions, InitialDisplayOptions, ActionEvent, PopupAction } from "../Popup/types.js"; import type { GoTo, GoToProperties } from "../support/GoTo.js"; import type { GoToParameters } from "../support/types.js"; import type { ActionToggleProperties } from "../../support/actions/ActionToggle.js"; import type { ActionButtonProperties } from "../../support/actions/ActionButton.js"; import type { ReadonlyArrayOrCollection } from "../../core/Collection.js"; import type { PointProperties } from "../../geometry/Point.js"; export interface FeaturesViewModelProperties extends GoToProperties, Partial<Pick<FeaturesViewModel, "activeFeature" | "autoCloseEnabled" | "browseClusterEnabled" | "content" | "defaultPopupTemplateEnabled" | "featureMenuOpen" | "featureMenuTitle" | "featurePage" | "features" | "featuresPerPage" | "featureViewModelAbilities" | "highlightEnabled" | "includeDefaultActions" | "initialDisplayMode" | "map" | "promises" | "screenLocationEnabled" | "selectedFeatureIndex" | "title" | "updateLocationEnabled" | "view" | "visible" | "zoomFactor">> { /** * [Collection](https://developers.arcgis.com/javascript/latest/references/core/core/Collection/) of [action](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionButton/) or [action toggle](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionToggle/) objects. * Each action may be executed by clicking the icon or image symbolizing them. * By default, every popup and Features widget has a `Zoom To` action styled with a magnifying glass icon ![popupTemplate-zoom-action](https://developers.arcgis.com/javascript/latest/assets/references/core/widgets/popup/popuptemplate-zoom-action.png). * When this icon is clicked, the view zooms in four LODs and centers on the selected feature. * * You may remove this default action by setting [includeDefaultActions](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#includeDefaultActions) to `false`, or by setting the * [PopupTemplate.overwriteActions](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/#overwriteActions) property to `true` in a [PopupTemplate](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/). * The order of each action is the order in which they appear in the actions [Collection](https://developers.arcgis.com/javascript/latest/references/core/core/Collection/). * * The [@trigger-action](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#event-trigger-action) event fires each time an action is clicked. * * Actions are defined with the properties listed in the [ActionButton](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionButton/) or [ActionToggle](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionToggle/) class. * * @see [@trigger-action](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#event-trigger-action) * @see [Sample - Popup actions](https://developers.arcgis.com/javascript/latest/sample-code/popup-actions/) * @example * // Defines an action button to zoom out from the selected feature * const zoomOutAction = { * type: "button", * // This text is displayed as a tooltip * title: "Zoom out", * // The ID by which to reference the action in the event handler * id: "zoom-out", * // Sets the icon used to style the action button * icon: "magnifying-glass-minus" * }; * // Adds the custom action to the popup. * view.popup.viewModel.actions.push(zoomOutAction); * * // Adds the custom action to the Features widget * featuresWidget.viewModel.actions.push(zoomOutAction); */ actions?: ReadonlyArrayOrCollection<((ActionButtonProperties & { type: "button" }) | (ActionToggleProperties & { type: "toggle" }))>; /** * Geometry used to show the location of the feature. This is automatically set when selecting a feature. If displaying content not related * to features in the map, such as the results from a task, then you must set this * property before making the widget [visible](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#visible) to the user. * * @see [Get started with popups](https://developers.arcgis.com/javascript/latest/sample-code/intro-popup/) * @example * // Sets the location of the popup to the center of the view * view.popup.viewModel.location = view.center; * // Displays the popup * view.popup.visible = true; * @example * // Display a popup when and where the user clicks the view. * reactiveUtils.on(()=>view, "click", ({ mapPoint })=>{ * view.popup.viewModel.location = mapPoint; * view.popup.visible = true; * }); */ location?: PointProperties | null; /** * The spatial reference used for [Arcade](https://developers.arcgis.com/arcade) operations. * This property should be set if Arcade expressions are executed that contain [geometry functions](https://developers.arcgis.com/arcade/function-reference/geometry_functions/). * * Alternatively, the [view](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#view) property can be used to provide the spatial reference instance for this property. * * @since 4.30 * @see [Type system](https://developers.arcgis.com/arcade/guide/types/#featuresetcollection) * @see [Arcade Profiles: Popup](https://developers.arcgis.com/arcade/profiles/popup/) */ spatialReference?: SpatialReferenceProperties | null; /** * Dates and times will be displayed in this time zone. By default this time zone is * inherited from [MapView.timeZone](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/#timeZone) if the [view](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#view) property is set. When a MapView is not associated with the widget view model, * 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](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). * * @since 4.30 */ timeZone?: TimeZone | null; } export interface FeaturesViewModelEvents { /** * Fires after the user clicks on an [action](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionButton/) or [action toggle](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionToggle/) in the action bar. This * event may be used to define a custom function to execute when particular * actions are clicked. See the example below for details of how this works. * * @see [Popup.actions](https://developers.arcgis.com/javascript/latest/references/core/widgets/Popup/#actions) * @see [PopupTemplate.actions](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/#actions) * @see [Features.open()](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/#open) * @example * featuresWidget.open({ * location: event.mapPoint, * fetchFeatures: true, * featureMenuOpen: true, * actions: [{ * // This text is displayed as a tooltip * title: "Zoom out", * // The ID used to reference this action in the event handler * id: "zoom-out", * // Sets the icon font used to style the action button * className: "esri-icon-zoom-out-magnifying-glass" * }, * { * title: "Delete Feature", * id: "delete-feature-action", * icon: "trash" * }] * }); * * // Fires each time an action is clicked * reactiveUtils.on(()=> featuresWidget, "trigger-action", (event)=>{ * // If the zoom-out action is clicked, execute the following code * if(event.action.id === "zoom-out"){ * // Zoom out two levels (LODs) * view.goTo({ * center: view.center, * zoom: view.zoom - 2 * }); * } * }); * @example * // Defines an action button to zoom out from the selected feature * const zoomOutAction = { * type: "button", * // This text is displayed as a tooltip * title: "Zoom out", * // The ID by which to reference the action in the event handler * id: "zoom-out", * // Sets the icon used to style the action button * icon: "magnifying-glass-minus" * }; * // Adds the custom action to the popup. * view.popup.actions.push(zoomOutAction); * * // This event fires for each click on any action * reactiveUtils.on(()=>view.popup?.viewModel, "trigger-action", (event)=>{ * // If the zoom-out action is clicked, fire the zoomOut() function * if(event.action.id === "zoom-out"){ * // in this case the view zooms out two LODs on each click * view.goTo({ * center: view.center, * zoom: view.zoom - 2 * }); * } * }); * @example * // Defines an action button to zoom out from the selected feature * const zoomOutAction = { * type: "button", * // This text is displayed as a tooltip * title: "Zoom out", * // The ID by which to reference the action in the event handler * id: "zoom-out", * // Sets the icon used to style the action button * icon: "magnifying-glass-minus" * }; * // Adds the custom action to the popup. * view.popup.actions.push(zoomOutAction); * * // This event fires for each click on any action * reactiveUtils.on(()=>view.popup?.popupViewModel, "trigger-action", (event)=>{ * // If the zoom-out action is clicked, fire the zoomOut() function * if(event.action.id === "zoom-out"){ * // in this case the view zooms out two LODs on each click * view.goTo({ * center: view.center, * zoom: view.zoom - 2 * }); * } * }); */ "trigger-action": ActionEvent; } /** * Provides the logic for the [Features](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/) widget and [component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-features/). * * @since 4.27 * @see [Features](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/) widget - _Deprecated since 4.34. Use the [Features component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-features) instead._ * @see [Features component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-features/) * @see [PopupTemplate](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/) * @see [Guide - Esri Icon Font](https://developers.arcgis.com/javascript/latest/esri-icon-font/) */ export default class FeaturesViewModel extends FeaturesViewModelSuperclass { /** * @deprecated * Do not directly reference this property. * Use EventNames and EventTypes helpers from \@arcgis/core/Evented */ "@eventTypes": FeaturesViewModelEvents; constructor(properties?: FeaturesViewModelProperties); /** * [Collection](https://developers.arcgis.com/javascript/latest/references/core/core/Collection/) of [action](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionButton/) or [action toggle](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionToggle/) objects. * Each action may be executed by clicking the icon or image symbolizing them. * By default, every popup and Features widget has a `Zoom To` action styled with a magnifying glass icon ![popupTemplate-zoom-action](https://developers.arcgis.com/javascript/latest/assets/references/core/widgets/popup/popuptemplate-zoom-action.png). * When this icon is clicked, the view zooms in four LODs and centers on the selected feature. * * You may remove this default action by setting [includeDefaultActions](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#includeDefaultActions) to `false`, or by setting the * [PopupTemplate.overwriteActions](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/#overwriteActions) property to `true` in a [PopupTemplate](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/). * The order of each action is the order in which they appear in the actions [Collection](https://developers.arcgis.com/javascript/latest/references/core/core/Collection/). * * The [@trigger-action](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#event-trigger-action) event fires each time an action is clicked. * * Actions are defined with the properties listed in the [ActionButton](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionButton/) or [ActionToggle](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionToggle/) class. * * @see [@trigger-action](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#event-trigger-action) * @see [Sample - Popup actions](https://developers.arcgis.com/javascript/latest/sample-code/popup-actions/) * @example * // Defines an action button to zoom out from the selected feature * const zoomOutAction = { * type: "button", * // This text is displayed as a tooltip * title: "Zoom out", * // The ID by which to reference the action in the event handler * id: "zoom-out", * // Sets the icon used to style the action button * icon: "magnifying-glass-minus" * }; * // Adds the custom action to the popup. * view.popup.viewModel.actions.push(zoomOutAction); * * // Adds the custom action to the Features widget * featuresWidget.viewModel.actions.push(zoomOutAction); */ get actions(): Collection<PopupAction>; set actions(value: ReadonlyArrayOrCollection<((ActionButtonProperties & { type: "button" }) | (ActionToggleProperties & { type: "toggle" }))>); /** * Indicates if the view model is active when it is visible and is not [waiting for results](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#waitingForResult). * * @see [waitingForResult](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#waitingForResult) * @see [visible](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#visible) */ get active(): boolean; /** * The highlighted feature on the map that is either hovered over or in focus within the feature menu. * * @since 4.32 */ accessor activeFeature: Graphic | null | undefined; /** A collection of [actions](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionButton/) or [action toggles](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionToggle/). */ get allActions(): Collection<PopupAction>; /** * This closes the container when the [View](https://developers.arcgis.com/javascript/latest/references/core/views/View/) camera or [Viewpoint](https://developers.arcgis.com/javascript/latest/references/core/Viewpoint/) changes. * * @default false */ accessor autoCloseEnabled: boolean; /** * Indicates if the "Browse features" experience is active in a * [cluster](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FeatureReductionCluster/) popup. This value becomes * `true` when the user enables feature browsing with the "Browse features" cluster * [action button](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionButton/). * It becomes `false` when the view scale changes, when the widget is closed, or when the user disables * the "Browse features" action. This should only be set programmatically when the * [selectedFeature](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#selectedFeature) is * an [aggregate graphic](https://developers.arcgis.com/javascript/latest/references/core/Graphic/#isAggregate) and represents a cluster. * * @default false * @example * // open the browse features experience for a cluster graphic * featuresWidget.viewModel.browseClusterEnabled = featuresWidget.viewModel.selectedFeature?.isAggregate; * * view.popup.viewModel.browseClusterEnabled = view.popup.viewModel.selectedFeature?.isAggregate; */ accessor browseClusterEnabled: boolean; /** * The information to display. When this property is set, this content may * only be static and cannot use fields to set content templates. To set a template * for the content based on field or attribute names, see * [PopupTemplate.content](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/#content). * * @see [Sample - Popup Docking](https://developers.arcgis.com/javascript/latest/sample-code/popup-docking-position/) * @example * // This sets generic instructions in the popup that will always be displayed * // unless it is overridden by a PopupTemplate. * // This can be set on the Features widget view model * featuresWidget.viewModel.content = "Click a feature on the map to view its attributes"; * * // Or set on the Popup widget view model. * view.popup.viewModel.content = "Click a feature on the map to view its attributes"; */ accessor content: string | HTMLElement | Widget | null | undefined; /** * A read-only property that specifies a [Collection](https://developers.arcgis.com/javascript/latest/references/core/core/Collection/) of action [buttons](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionButton/) and/or [toggles](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionToggle/). * By default, there is a "Zoom to" action that allows users to zoom to the selected feature. * * > [!WARNING] * > * > In order to disable any default actions, it is necessary to set [includeDefaultActions](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#includeDefaultActions) to `false`. */ get defaultActions(): Collection<PopupAction>; /** * 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](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/), * [GeoJSONLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/), * [OGCFeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/OGCFeatureLayer/), * [SceneLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/SceneLayer/), * [CSVLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/CSVLayer/), * [PointCloudLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/PointCloudLayer/), * [StreamLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/StreamLayer/), and * [ImageryLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/ImageryLayer/)). * * @default false */ accessor defaultPopupTemplateEnabled: boolean; /** * The number of selected [features](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#features) available. * * @default 0 */ get featureCount(): number; /** * This property enables showing the list of features. * Setting this to `true` allows the user to scroll through the list of features. * This value will only be honored if [initialDisplayMode](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#initialDisplayMode) is set to `feature`. * * @default false * @since 4.32 */ accessor featureMenuOpen: boolean; /** The title to display on the widget while viewing the feature menu. */ accessor featureMenuTitle: string | null | undefined; /** * The current page number in the feature browsing menu. If the feature menu is not open, this value is `null`. * This value is dependent on the [featuresPerPage](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#featuresPerPage). * * @since 4.32 */ accessor featurePage: number | null | undefined; /** * An array of features. Each graphic in this array must * have a valid [PopupTemplate](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/) set. They may share the same * [PopupTemplate](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/) or have unique * [PopupTemplates](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/) depending on their attributes. * The [content](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#content) and [title](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#title) properties * are set based on the `content` and `title` properties of each graphic's respective * [PopupTemplate](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/). * * When more than one graphic exists in this array, the current content of the * Popup is set based on the value of the [selected feature](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#selectedFeature). * * This value is `null` if there are no features associated with the view model. * * @example * // When setting the features property, the graphics pushed to this property * // must have a PopupTemplate set. * let g1 = new Graphic(); * g1.popupTemplate = new PopupTemplate({ * title: "Results title", * content: "Results: {ATTRIBUTE_NAME}" * }); * // Create an array of graphics and set this to the features property. The content and title of * // will be set depending on the PopupTemplate of the graphics. * // Each graphic may share the same PopupTemplate or have a unique PopupTemplate. * let graphics = [g1, g2, g3, g4, g5]; * // This value can be set on the popup or Features view model. * view.popup.viewModel.features = graphics; * featuresWidget.viewModel.features = graphics; */ accessor features: Graphic[]; /** * The number of features to fetch at one time. * * @default 20 */ accessor featuresPerPage: number; /** Defines the specific [Abilities](https://developers.arcgis.com/javascript/latest/references/core/widgets/Feature/types/#Abilities) that can be used when querying and displaying content. */ accessor featureViewModelAbilities: FeatureViewModelAbilities | null | undefined; /** An array of [feature view model(s)](https://developers.arcgis.com/javascript/latest/references/core/widgets/Feature/FeatureViewModel/). */ get featureViewModels(): FeatureViewModel[]; /** * Highlight the selected feature using one of the [HighlightOptions](https://developers.arcgis.com/javascript/latest/references/core/views/support/HighlightOptions/) defined in the view's * [View.highlights](https://developers.arcgis.com/javascript/latest/references/core/views/View/#highlights) collection. * * @default true */ accessor highlightEnabled: boolean; /** * Indicates whether or not to include [defaultActions](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#defaultActions). * * > [!WARNING] * > * > In order to disable any [default actions](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#defaultActions), it is necessary to set [includeDefaultActions](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#includeDefaultActions) to `false`. * * @default true * @example * // Removes the default actions * viewModel.includeDefaultActions = false; */ accessor includeDefaultActions: boolean; /** * Indicates whether to initially display a list of features, or the content for one feature. * * @default "feature" * @since 4.32 */ accessor initialDisplayMode: InitialDisplayOptions; /** * Geometry used to show the location of the feature. This is automatically set when selecting a feature. If displaying content not related * to features in the map, such as the results from a task, then you must set this * property before making the widget [visible](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#visible) to the user. * * @see [Get started with popups](https://developers.arcgis.com/javascript/latest/sample-code/intro-popup/) * @example * // Sets the location of the popup to the center of the view * view.popup.viewModel.location = view.center; * // Displays the popup * view.popup.visible = true; * @example * // Display a popup when and where the user clicks the view. * reactiveUtils.on(()=>view, "click", ({ mapPoint })=>{ * view.popup.viewModel.location = mapPoint; * view.popup.visible = true; * }); */ get location(): Point | null | undefined; set location(value: PointProperties | null | undefined); /** * A map is required when the input [features](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#features) have a popupTemplate that contains [Arcade](https://developers.arcgis.com/arcade) expressions in [ExpressionInfo](https://developers.arcgis.com/javascript/latest/references/core/popup/ExpressionInfo/) or [ExpressionContent](https://developers.arcgis.com/javascript/latest/references/core/popup/content/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](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#view) property can be used to provide the map instance for this property. * * @since 4.30 * @see [Type system](https://developers.arcgis.com/arcade/guide/types/#featuresetcollection) * @see [Arcade Profiles: Popup](https://developers.arcgis.com/arcade/profiles/popup/) * @example * // The building footprints represent the buildings that intersect a clicked parcel * let buildingFootprints = Intersects($feature, FeatureSetByName($map, "Building Footprints")); */ accessor map: EsriMap | null | undefined; /** * The number of [promises](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#promises) remaining to be resolved. * * @default 0 * @see [promises property](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#promises) */ get pendingPromisesCount(): number; /** * The number of selected [promises](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#promises) available. * * @default 0 */ get promiseCount(): number; /** * An array of pending Promises that have not yet been fulfilled. If there are * no pending Promises, the value is `null`. When the pending Promises are * resolved they are removed from this array and the features they return * are pushed into the [features](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#features) array. */ accessor promises: Promise<Graphic[]>[]; /** * The screen location of the selected feature. * * @since 4.32 */ get screenLocation(): ScreenPoint | null | undefined; /** * Determines whether screen point tracking is active for positioning. * * @default false * @since 4.32 */ screenLocationEnabled: boolean; /** * The graphic used to represent the cluster extent when the `Browse features` action * is active. Only applies when a PopupTemplate is set on * a [FeatureReductionCluster](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FeatureReductionCluster/) instance. */ get selectedClusterBoundaryFeature(): Graphic; /** * The selected feature accessed. The [content](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#content) is * determined based on the [PopupTemplate](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/) assigned to * this feature. */ get selectedFeature(): Graphic | null; /** * Index of the feature that is [selected](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#selectedFeature). When [features](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#features) are set, * the first index is automatically selected. */ accessor selectedFeatureIndex: number; /** * The [view model](https://developers.arcgis.com/javascript/latest/references/core/widgets/Feature/FeatureViewModel/) of the selected feature. * * @since 4.32 */ get selectedFeatureViewModel(): FeatureViewModel; /** * The spatial reference used for [Arcade](https://developers.arcgis.com/arcade) operations. * This property should be set if Arcade expressions are executed that contain [geometry functions](https://developers.arcgis.com/arcade/function-reference/geometry_functions/). * * Alternatively, the [view](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#view) property can be used to provide the spatial reference instance for this property. * * @since 4.30 * @see [Type system](https://developers.arcgis.com/arcade/guide/types/#featuresetcollection) * @see [Arcade Profiles: Popup](https://developers.arcgis.com/arcade/profiles/popup/) */ get spatialReference(): SpatialReference | null | undefined; set spatialReference(value: SpatialReferenceProperties | null | undefined); /** * The view model's state. * * @default "disabled" */ get state(): State; /** * Dates and times will be displayed in this time zone. By default this time zone is * inherited from [MapView.timeZone](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/#timeZone) if the [view](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#view) property is set. When a MapView is not associated with the widget view model, * 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](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). * * @since 4.30 */ get timeZone(): TimeZone; set timeZone(value: TimeZone | null | undefined); /** * The title of the widget. This can be set to any string value no * matter the features that are selected. If the [selected feature](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#selectedFeature) * has a [PopupTemplate](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/), then the title set in the * corresponding template is used here. * * @example * // This title will display in the popup unless a selected feature's * // PopupTemplate overrides it. * view.popup.viewModel.title = "Population by zip codes in Southern California"; */ accessor title: string | null | undefined; /** * Indicates whether to update the [location](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#location) when the [selectedFeatureIndex](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#selectedFeatureIndex) changes. * * @default false * @since 4.32 */ accessor updateLocationEnabled: boolean; /** * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/) or [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/). * * > [!WARNING] * > * > The FeaturesViewModel requires a view if the user expects it to display content in any of the following situations: * > - The [features](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#features) have a popupTemplate containing Arcade expressions in [ExpressionInfo](https://developers.arcgis.com/javascript/latest/references/core/popup/ExpressionInfo/) or [ExpressionContent](https://developers.arcgis.com/javascript/latest/references/core/popup/content/ExpressionContent/) that may use [geometry functions](https://developers.arcgis.com/arcade/function-reference/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](https://developers.arcgis.com/javascript/latest/references/core/Graphic/#isAggregate) (i.e. a [cluster](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FeatureReductionCluster/) or [bin](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FeatureReductionBinning/)). * > - Values from `date` and `timestamp-offset` [fields](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Field/#type) should respect the view's [time zone](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/#timeZone). * > - When using the [fetchFeatures()](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#fetchFeatures) method or the `fetchFeatures` option in the [open()](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#open) method. */ accessor view: MapViewOrSceneView | null | undefined; /** * Indicates whether the widget is visible. This property is `true` when the widget is querying for results, even if it is not open in the view. * Use the [active](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#active) property to check if the widget is visible and is not [waiting for results](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#waitingForResult). * * @default false * @see [active](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#active) */ accessor visible: boolean; /** * Indicates whether the widget is waiting for content to be resolved. * * @since 4.32 */ get waitingForContents(): boolean; /** * Indicates whether a feature was found while resolving [promises](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#promises). * * @default false * @see [active](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#active) */ get waitingForResult(): boolean; /** * Number of levels of detail (LOD) to zoom in on the [selected feature](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#selectedFeature). * * @default 4 * @since 4.34 * @example * // Restricts the zooming to two LODS when the zoom in action is clicked. * features.viewModel.zoomFactor = 2; */ accessor zoomFactor: number; /** * Removes all [promises](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#promises), [features](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#features), [content](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#content), and * [title](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#title). */ clear(): void; /** * Use this method to return feature(s) at a given screen location. * These features are fetched from all of the * [LayerViews](https://developers.arcgis.com/javascript/latest/references/core/views/layers/LayerView/) in the * [View](https://developers.arcgis.com/javascript/latest/references/core/views/View/). In order to use this, a layer must already have an * associated [PopupTemplate](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/) and have its * [FeatureLayer.popupEnabled](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#popupEnabled). * These features can then be used within a custom [Popup](https://developers.arcgis.com/javascript/latest/references/core/widgets/Popup/), [Features](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/), * or [Feature](https://developers.arcgis.com/javascript/latest/references/core/widgets/Feature/) widget experience. * One example could be a custom side panel that displays feature-specific information based on * an end user's click location. This method allows a developer the ability to * control how the input location is handled, and then subsequently, what to do with the results. * * @param screenPoint - An object representing a point on the screen. This point can be in either the * [ScreenPoint](https://developers.arcgis.com/javascript/latest/references/core/core/types/#ScreenPoint) or * [ScreenPoint](https://developers.arcgis.com/javascript/latest/references/core/core/types/#ScreenPoint). * @param options - The [options](https://developers.arcgis.com/javascript/latest/references/core/widgets/Popup/types/#FetchFeaturesOptions) * to pass into the `fetchFeatures` method. * @returns Resolves with the selected `hitTest` * location. In addition, it also returns an array of [graphics](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) if the `hitTest` is * performed directly on the [View](https://developers.arcgis.com/javascript/latest/references/core/views/View/), a single Promise containing an array of all resulting * [graphics](https://developers.arcgis.com/javascript/latest/references/core/Graphic/), or an array of objects containing this array of resulting [graphics](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) in addition to its associated * [LayerView](https://developers.arcgis.com/javascript/latest/references/core/views/layers/LayerView/). * * Most commonly if accessing all features, use the single promise returned in the * [result's allGraphicsPromise](https://developers.arcgis.com/javascript/latest/references/core/views/types/#FetchPopupFeaturesResult) and call `.then()` as seen in * the example snippet. * @example * // Get view's click event * reactiveUtils.on(()=>view, "click", (event) => { * // Call fetchFeatures and pass in the click event screenPoint * viewModel.fetchFeatures(event.screenPoint).then((response) => { * // Access the response from fetchFeatures * response.allGraphicsPromise.then((graphics) => { * // Do something with the returned graphic from fetchFeatures such as setting this to the * // Features widget graphic property. * featureWidget.graphic = graphics[0]; * }); * }); * }); */ fetchFeatures(screenPoint: ScreenPoint | null | undefined, options?: FetchFeaturesOptions): Promise<FetchPopupFeaturesResult>; /** * Selects the feature at the next index in relation to the selected feature. * * @returns Returns an instance of the popup's view model. * @see [selectedFeatureIndex](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#selectedFeatureIndex) */ next(): FeaturesViewModel; /** * Opens the widget at the given location with content defined either explicitly with `content` * or driven from the [PopupTemplate](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/) of input features. This method sets the * [visible](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#visible) property to `true`. Users can alternatively set the [visible](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#visible) property to `true`. * * @param options - Defines the location and content of the popup when opened. * @see [Intro to popups](https://developers.arcgis.com/javascript/latest/sample-code/intro-popup/) * @see [Popup.visible](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#visible) * @see [Sample - Query with `rest/query`](https://developers.arcgis.com/javascript/latest/sample-code/query/) * @example * // Manually opens the corresponding widget. * reactiveUtils.on(()=>view, "click", (event)=>{ * viewModel.open({ * location: event.mapPoint, * title: "You clicked here", * content: "This is a point of interest" * }); * }); * @example * // Displays the content for the selected feature if a popupTemplate is defined at the view * // click event location. * reactiveUtils.on(()=>view, "click", (event)=>{ * view.popup.viewModel.open({ * location: event.mapPoint, * fetchFeatures: true * }); * }); * @example * // Opens the corresponding widget with the specified title and content and updates * // the location of the popup based on the selected feature's geometry. * view.popup.viewModel.open({ * title: "You clicked here", * content: "This is a point of interest", * updateLocationEnabled: true * }); * @example * // Opens the Features widget with the specified graphics. * // This will only work if the array of graphics have a popup template defined. * featuresWidget.viewModel.open({ * features: graphics * }); */ open(options?: PopupOpenOptions): void; /** * Selects the feature at the previous index in relation to the selected feature. * * @returns Returns an instance of the popup's view model. * @see [selectedFeatureIndex](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#selectedFeatureIndex) */ previous(): FeaturesViewModel; /** * Triggers the [@trigger-action](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#event-trigger-action) event and executes the [action](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#actions) * at the specified index in the [actions](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#actions) array. * * @param actionIndex - The index of the [action](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#actions) to execute. */ triggerAction(actionIndex: number): void; /** * Sets the view to a given target. If [goToOverride](https://developers.arcgis.com/javascript/latest/references/core/widgets/Features/FeaturesViewModel/#goToOverride) is set, `goToOverride()` will be called with the current view and specified `params`. * Otherwise, the view will be set using the provided `params`. * * @param params - The parameters to pass to the `zoomTo()` method. * @returns A promise that resolves when the view's extent updates to the value defined in `params.target`. * @since 4.32 * @see [MapView.goTo()](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/#goTo) or [SceneView.goTo()](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#goTo) */ zoomTo(params: GoToParameters): Promise<void>; } declare const FeaturesViewModelSuperclass: typeof EventedAccessor & typeof GoTo