PopupViewModel

AMD: require(["esri/widgets/Popup/PopupViewModel"], (PopupVM) => { /* code goes here */ });
ESM: import PopupVM from "@arcgis/core/widgets/Popup/PopupViewModel.js";
Class: esri/widgets/Popup/PopupViewModel
Inheritance: PopupViewModel FeaturesViewModel Accessor
Since: ArcGIS Maps SDK for JavaScript 4.0

Provides the logic for the Popup widget, which allows users to view content from feature attributes. Popups enhance web applications by providing users with a simple way to interact with and view attributes in a layer. They play an important role in relaying information to the user, which improves the storytelling capabilities of the application.

See also

Constructors

PopupViewModel

Constructor
new PopupViewModel(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

Collection of action or action toggle objects.

FeaturesViewModel

Indicates if the view model is active when it is visible and is not waiting for results.

FeaturesViewModel

A collection of actions or action toggles.

FeaturesViewModel

This closes the container when the View camera or Viewpoint changes.

FeaturesViewModel

Indicates if the "Browse features" experience is active in a cluster popup.

FeaturesViewModel

The information to display.

FeaturesViewModel

The name of the class.

Accessor

A read-only property that specifies a Collection of action buttons and/or toggles.

FeaturesViewModel

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

FeaturesViewModel

The number of selected features available.

FeaturesViewModel

An array of features.

FeaturesViewModel

The number of features to fetch at one time.

FeaturesViewModel

Defines the specific abilities that can be used when querying and displaying content.

FeaturesViewModel

An array of feature view model(s).

FeaturesViewModel

This function provides the ability to override either the MapView goTo() or SceneView goTo() methods.

FeaturesViewModel

Highlight the selected feature using the highlightOptions set on the MapView or the highlightOptions set on the SceneView.

FeaturesViewModel

Indicates whether or not to include defaultActions.

FeaturesViewModel

Geometry used to show the location of the feature.

FeaturesViewModel

A map is required when the input features have 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.

FeaturesViewModel

The number of promises remaining to be resolved.

FeaturesViewModel

The number of selected promises available.

FeaturesViewModel

An array of pending Promises that have not yet been fulfilled.

FeaturesViewModel

The graphic used to represent the cluster extent when the Browse features action is active.

FeaturesViewModel

The selected feature accessed.

FeaturesViewModel

Index of the feature that is selected.

FeaturesViewModel

The spatial reference used for Arcade operations.

FeaturesViewModel

The view model's state.

FeaturesViewModel

Dates and times will be displayed in this time zone.

FeaturesViewModel

The title of the widget.

FeaturesViewModel

A reference to the MapView or SceneView.

FeaturesViewModel

Indicates whether the widget is visible.

FeaturesViewModel

Indicates whether a feature was found while resolving promises.

FeaturesViewModel

Property Details

actions

Inherited
Property
actions Collection<(ActionButton|ActionToggle)>autocast
Inherited from FeaturesViewModel
Autocasts from Object[]

Collection of action or action toggle 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. 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 to false, or by setting the overwriteActions property to true in a PopupTemplate. The order of each action is the order in which they appear in the actions Collection.

The trigger-action event fires each time an action is clicked.

Actions are defined with the properties listed in the ActionButton or ActionToggle class.

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);

active

Inherited
Property
active Booleanreadonly
Inherited from FeaturesViewModel
Since: ArcGIS Maps SDK for JavaScript 4.17 FeaturesViewModel since 4.27, active added at 4.17.

Indicates if the view model is active when it is visible and is not waiting for results.

allActions

Inherited
Property
allActions Collection<(ActionButton|ActionToggle)>readonly
Inherited from FeaturesViewModel
Since: ArcGIS Maps SDK for JavaScript 4.8 FeaturesViewModel since 4.27, allActions added at 4.8.

A collection of actions or action toggles.

autoCloseEnabled

Inherited
Property
autoCloseEnabled Boolean
Inherited from FeaturesViewModel
Since: ArcGIS Maps SDK for JavaScript 4.5 FeaturesViewModel since 4.27, autoCloseEnabled added at 4.5.

This closes the container when the View camera or Viewpoint changes.

Default Value:false

browseClusterEnabled

Inherited
Property
browseClusterEnabled Boolean
Inherited from FeaturesViewModel
Since: ArcGIS Maps SDK for JavaScript 4.24 FeaturesViewModel since 4.27, browseClusterEnabled added at 4.24.

Indicates if the "Browse features" experience is active in a cluster popup. This value becomes true when the user enables feature browsing with the "Browse features" cluster action button. 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 is an aggregate graphic and represents a cluster.

Default Value: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;

content

Inherited
Property
content String |HTMLElement |Widget
Inherited from FeaturesViewModel

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.

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";

declaredClass

Inherited
Property
declaredClass Stringreadonly
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.7 Accessor since 4.0, declaredClass added at 4.7.

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

defaultActions

Inherited
Property
defaultActions Collection<(ActionButton|ActionToggle)>readonly
Inherited from FeaturesViewModel
Since: ArcGIS Maps SDK for JavaScript 4.19 FeaturesViewModel since 4.27, defaultActions added at 4.19.

A read-only property that specifies a Collection of action buttons and/or toggles. By default, there is a "Zoom to" action that allows users to zoom to the selected feature.

In order to disable any default actions, it is necessary to set includeDefaultActions to false.

defaultPopupTemplateEnabled

Inherited
Property
defaultPopupTemplateEnabled Boolean
Inherited from FeaturesViewModel
Since: ArcGIS Maps SDK for JavaScript 4.11 FeaturesViewModel since 4.27, 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.12, PopupTemplate content can no longer be set using a wildcard, e.g. *. Instead, set the defaultPopupTemplateEnabled property to true.
  • Starting with version 4.28, date fields are formatted using the short-date-short-time preset dateFormat rather than long-month-day-year in default popup templates created by setting the defaultPopupTemplateEnabled property to true. 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

featureCount

Inherited
Property
featureCount Numberreadonly
Inherited from FeaturesViewModel

The number of selected features available.

Default Value:0

features

Inherited
Property
features Graphic[]
Inherited from FeaturesViewModel

An array of features. Each graphic in this array must have a valid PopupTemplate set. They may share the same PopupTemplate or have unique PopupTemplates depending on their attributes. The content and title properties are set based on the content and title properties of each graphic's respective 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.

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;

featuresPerPage

Inherited
Property
featuresPerPage Number
Inherited from FeaturesViewModel

The number of features to fetch at one time.

Default Value:20

featureViewModelAbilities

Inherited
Property
featureViewModelAbilities Abilitiesautocast
Inherited from FeaturesViewModel
Since: ArcGIS Maps SDK for JavaScript 4.21 FeaturesViewModel since 4.27, featureViewModelAbilities added at 4.21.

Defines the specific abilities that can be used when querying and displaying content.

featureViewModels

Inherited
Property
featureViewModels FeatureViewModel[]readonly
Inherited from FeaturesViewModel
Since: ArcGIS Maps SDK for JavaScript 4.21 FeaturesViewModel since 4.27, featureViewModels added at 4.21.

An array of feature view model(s).

goToOverride

Inherited
Property
goToOverride GoToOverride
Inherited from FeaturesViewModel
Since: ArcGIS Maps SDK for JavaScript 4.8 FeaturesViewModel since 4.27, goToOverride added at 4.8.

This function provides the ability to override either the MapView goTo() or SceneView goTo() methods.

See also
Example
// The following snippet uses the Search widget but can be applied to any
// widgets that support the goToOverride property.
search.goToOverride = function(view, goToParams) {
  goToParams.options = {
    duration: updatedDuration
  };
  return view.goTo(goToParams.target, goToParams.options);
};

highlightEnabled

Inherited
Property
highlightEnabled Boolean
Inherited from FeaturesViewModel
Since: ArcGIS Maps SDK for JavaScript 4.4 FeaturesViewModel since 4.27, highlightEnabled added at 4.4.

Highlight the selected feature using the highlightOptions set on the MapView or the highlightOptions set on the SceneView.

Default Value:true

includeDefaultActions

Inherited
Property
includeDefaultActions Boolean
Inherited from FeaturesViewModel
Since: ArcGIS Maps SDK for JavaScript 4.19 FeaturesViewModel since 4.27, includeDefaultActions added at 4.19.

Indicates whether or not to include defaultActions.

In order to disable any default actions, it is necessary to set includeDefaultActions to false.

Default Value:true
Example
// Removes the default actions
viewModel.includeDefaultActions = false;

location

Inherited
Property
location Point
Inherited from FeaturesViewModel

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 to the user.

Examples
// 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;
// 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;
});

map

Inherited
Property
map Map
Inherited from FeaturesViewModel
Since: ArcGIS Maps SDK for JavaScript 4.30 FeaturesViewModel since 4.27, map added at 4.30.

A map is required when the input features have 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"));

pendingPromisesCount

Inherited
Property
pendingPromisesCount Numberreadonly
Inherited from FeaturesViewModel

The number of promises remaining to be resolved.

Default Value:0
See also

promiseCount

Inherited
Property
promiseCount Numberreadonly
Inherited from FeaturesViewModel

The number of selected promises available.

Default Value:0

promises

Inherited
Property
promises Promise[]
Inherited from FeaturesViewModel

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 array.

selectedClusterBoundaryFeature

Inherited
Property
selectedClusterBoundaryFeature Graphicreadonly
Inherited from FeaturesViewModel
Since: ArcGIS Maps SDK for JavaScript 4.19 FeaturesViewModel since 4.27, selectedClusterBoundaryFeature added at 4.19.

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 instance.

selectedFeature

Inherited
Property
selectedFeature Graphicreadonly
Inherited from FeaturesViewModel

The selected feature accessed. The content is determined based on the PopupTemplate assigned to this feature.

selectedFeatureIndex

Inherited
Property
selectedFeatureIndex Number
Inherited from FeaturesViewModel

Index of the feature that is selected. When features are set, the first index is automatically selected.

spatialReference

Inherited
Property
spatialReference SpatialReference
Inherited from FeaturesViewModel
Since: ArcGIS Maps SDK for JavaScript 4.30 FeaturesViewModel since 4.27, spatialReference added at 4.30.

The spatial reference used for Arcade operations. This property should be set if Arcade expressions are executed that contain geometry functions.

Alternatively, the view property can be used to provide the spatial reference instance for this property.

Default Value:null
See also

state

Inherited
Property
state Stringreadonly
Inherited from FeaturesViewModel

The view model's state.

Possible Values:"ready" |"disabled"

Default Value:disabled

timeZone

Inherited
Property
timeZone String
Inherited from FeaturesViewModel
Since: ArcGIS Maps SDK for JavaScript 4.30 FeaturesViewModel since 4.27, timeZone added at 4.30.

Dates and times will be displayed in this time zone. By default this time zone is inherited from MapView.timeZone if the 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.

title

Inherited
Property
title String
Inherited from FeaturesViewModel

The title of the widget. This can be set to any string value no matter the features that are selected. If the selected feature has a 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";

view

Inherited
Property
view MapView |SceneView
Inherited from FeaturesViewModel

A reference to the MapView or SceneView.

The FeaturesViewModel requires a view if the user expects it to display content in any of the following situations:

visible

Inherited
Property
visible Boolean
Inherited from FeaturesViewModel

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 property to check if the widget is visible and is not waiting for results.

Default Value:false
See also

waitingForResult

Inherited
Property
waitingForResult Booleanreadonly
Inherited from FeaturesViewModel
Since: ArcGIS Maps SDK for JavaScript 4.17 FeaturesViewModel since 4.27, waitingForResult added at 4.17.

Indicates whether a feature was found while resolving promises.

Default Value:false
See also

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.

Accessor

Removes all promises, features, content, and title.

FeaturesViewModel

Emits an event on the instance.

FeaturesViewModel

Use this method to return feature(s) at a given screen location.

FeaturesViewModel

Indicates whether there is an event listener on the instance that matches the provided event name.

FeaturesViewModel

Returns true if a named group of handles exist.

Accessor

Selects the feature at the next index in relation to the selected feature.

FeaturesViewModel

Registers an event handler on the instance.

FeaturesViewModel

Opens the widget at the given location with content defined either explicitly with content or driven from the PopupTemplate of input features.

FeaturesViewModel

Selects the feature at the previous index in relation to the selected feature.

FeaturesViewModel

Removes a group of handles owned by the object.

Accessor

Triggers the trigger-action event and executes the action at the specified index in the actions array.

FeaturesViewModel

Method Details

addHandles

Inherited
Method
addHandles(handleOrHandles, groupKey)
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor 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();
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.

clear

Inherited
Method
clear()
Inherited from FeaturesViewModel

Removes all promises, features, content, and title.

emit

Inherited
Method
emit(type, event){Boolean}
Inherited from FeaturesViewModel
Since: ArcGIS Maps SDK for JavaScript 4.5 FeaturesViewModel since 4.27, emit added at 4.5.

Emits an event on the instance. This method should only be used when creating subclasses of this class.

Parameters
type String

The name of the event.

event Object
optional

The event payload.

Returns
Type Description
Boolean true if a listener was notified

fetchFeatures

Inherited
Method
fetchFeatures(screenPoint, options){Promise<FetchPopupFeaturesResult>}
Inherited from FeaturesViewModel
Since: ArcGIS Maps SDK for JavaScript 4.15 FeaturesViewModel since 4.27, fetchFeatures added at 4.15.

Use this method to return feature(s) at a given screen location. These features are fetched from all of the LayerViews in the view. In order to use this, a layer must already have an associated PopupTemplate and have its popupEnabled. These features can then be used within a custom Popup, Features, or 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.

Parameters
screenPoint Object

An object representing a point on the screen. This point can be in either the MapView or SceneView.

Specification
x Number

The x coordinate.

y Number

The y coordinate.

optional

The options to pass into the fetchFeatures method.

Returns
Type Description
Promise<FetchPopupFeaturesResult> Resolves with the selected hitTest location. In addition, it also returns an array of graphics if the hitTest is performed directly on the view, a single Promise containing an array of all resulting graphics, or an array of objects containing this array of resulting graphics in addition to its associated layerview. Most commonly if accessing all features, use the single promise returned in the result's allGraphicsPromise 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];
    });
  });
});

hasEventListener

Inherited
Method
hasEventListener(type){Boolean}
Inherited from FeaturesViewModel

Indicates whether there is an event listener on the instance that matches the provided event name.

Parameter
type String

The name of the event.

Returns
Type Description
Boolean Returns true if the class supports the input event.

hasHandles

Inherited
Method
hasHandles(groupKey){Boolean}
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, hasHandles added at 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");
}

next

Inherited
Method
next(){FeaturesViewModel}
Inherited from FeaturesViewModel

Selects the feature at the next index in relation to the selected feature.

Returns
Type Description
FeaturesViewModel Returns an instance of the popup's view model.

on

Inherited
Method
on(type, listener){Object}
Inherited from FeaturesViewModel

Registers an event handler on the instance. Call this method to hook an event with a listener.

Parameters

An event or an array of events to listen for.

listener Function

The function to call when the event fires.

Returns
Type Description
Object Returns an event handler with a remove() method that should be called to stop listening for the event(s).
Property Type Description
remove Function When called, removes the listener from the event.
Example
view.on("click", function(event){
  // event is the event handle returned after the event fires.
  console.log(event.mapPoint);
});

open

Inherited
Method
open(options)
Inherited from FeaturesViewModel

Opens the widget at the given location with content defined either explicitly with content or driven from the PopupTemplate of input features. This method sets the visible property to true. Users can alternatively set the visible property to true.

Parameters
Specification
options Object
optional

Defines the location and content of the popup when opened.

Specification
title String
optional

Sets the title of the popup.

content String
optional

Sets the content of the popup.

fetchFeatures Boolean
optional
Default Value: false

Since: 4.12

When true, indicates the feature's content should be fetched and displayed. If no PopupTemplate exists, a default template is created for the layer if defaultPopupTemplateEnabled = true. In order for this option to work, there must be a valid view and location set.

location Point
optional

Sets the location, which is the geometry used to position the popup.

features Graphic[]
optional

Sets the features, which populates the title and content based on each graphic's PopupTemplate.

promises Promise[]
optional

Sets pending promises. The UI will display once the promises resolve. Each promise must resolve to an array of Graphics.

updateLocationEnabled Boolean
optional
Default Value: false

When true, indicates the location property will be updated for each paginated feature based on the selected feature's geometry.

Examples
// 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"
  });
});
// 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
   });
 });
// 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
});
// 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
});

previous

Inherited
Method
previous(){FeaturesViewModel}
Inherited from FeaturesViewModel

Selects the feature at the previous index in relation to the selected feature.

Returns
Type Description
FeaturesViewModel Returns an instance of the popup's view model.

removeHandles

Inherited
Method
removeHandles(groupKey)
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, removeHandles added at 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");

triggerAction

Inherited
Method
triggerAction(actionIndex)
Inherited from FeaturesViewModel

Triggers the trigger-action event and executes the action at the specified index in the actions array.

Parameter
actionIndex Number

The index of the action to execute.

Event Overview

Show inherited events Hide inherited events
Name Type Summary Class
{action: ActionButton|ActionToggle}

Fires after the user clicks on an action or action toggle in the action bar.

FeaturesViewModel

Event Details

trigger-action

Inherited
Event
trigger-action
Inherited from FeaturesViewModel

Fires after the user clicks on an action or action toggle 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.

Property

The action clicked by the user. For a description of this object and a specification of its properties, see the actions property of this class.

See also
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
    });
  }
});

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.