require(["esri/widgets/Popup/PopupViewModel"], (PopupVM) => { /* code goes here */ });
import PopupVM from "@arcgis/core/widgets/Popup/PopupViewModel.js";
esri/widgets/Popup/PopupViewModel
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
-
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 |
---|---|---|---|
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 | 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 | 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 | ||
FeaturesViewModel | |||
Indicates whether the widget is visible. | FeaturesViewModel | ||
Indicates whether a feature was found while resolving promises. | FeaturesViewModel |
Property Details
-
actions
InheritedPropertyactions Collection<(ActionButton|ActionToggle)>autocast
Inherited from FeaturesViewModel -
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 . 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 theoverwriteActions
property totrue
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
InheritedPropertyactive Booleanreadonly
Inherited from FeaturesViewModelSince: ArcGIS Maps SDK for JavaScript 4.17FeaturesViewModel 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.
- See also
-
allActions
InheritedPropertyallActions Collection<(ActionButton|ActionToggle)>readonly
Inherited from FeaturesViewModelSince: ArcGIS Maps SDK for JavaScript 4.8FeaturesViewModel since 4.27, allActions added at 4.8. -
A collection of actions or action toggles.
-
autoCloseEnabled
InheritedPropertyautoCloseEnabled Boolean
Inherited from FeaturesViewModelSince: ArcGIS Maps SDK for JavaScript 4.5FeaturesViewModel since 4.27, autoCloseEnabled added at 4.5. -
- Default Value:false
-
browseClusterEnabled
InheritedPropertybrowseClusterEnabled Boolean
Inherited from FeaturesViewModelSince: ArcGIS Maps SDK for JavaScript 4.24FeaturesViewModel 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 becomesfalse
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
InheritedPropertycontent 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.
- See also
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";
-
defaultActions
InheritedPropertydefaultActions Collection<(ActionButton|ActionToggle)>readonly
Inherited from FeaturesViewModelSince: ArcGIS Maps SDK for JavaScript 4.19FeaturesViewModel 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
InheritedPropertydefaultPopupTemplateEnabled Boolean
Inherited from FeaturesViewModelSince: ArcGIS Maps SDK for JavaScript 4.11FeaturesViewModel 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 thedefaultPopupTemplateEnabled
property totrue
. - Starting with version 4.28,
date
fields are formatted using theshort-date-short-time
preset dateFormat rather thanlong-month-day-year
in default popup templates created by setting thedefaultPopupTemplateEnabled
property totrue
. For example, previously a date that may have appeared as"December 30, 1997"
will now appear as"12/30/1997 6:00 PM"
.
- Default Value:false
- Starting with version 4.12, PopupTemplate content can no longer be set using a
wildcard, e.g.
-
featureCount
InheritedPropertyfeatureCount Numberreadonly
Inherited from FeaturesViewModel -
The number of selected features available.
- Default Value:0
-
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
andtitle
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
InheritedPropertyfeaturesPerPage Number
Inherited from FeaturesViewModel -
The number of features to fetch at one time.
- Default Value:20
-
Inherited from FeaturesViewModel
Since: ArcGIS Maps SDK for JavaScript 4.21FeaturesViewModel since 4.27, featureViewModelAbilities added at 4.21. -
Defines the specific abilities that can be used when querying and displaying content.
-
featureViewModels
InheritedPropertyfeatureViewModels FeatureViewModel[]readonly
Inherited from FeaturesViewModelSince: ArcGIS Maps SDK for JavaScript 4.21FeaturesViewModel since 4.27, featureViewModels added at 4.21. -
An array of feature view model(s).
-
goToOverride
InheritedPropertygoToOverride GoToOverride
Inherited from FeaturesViewModelSince: ArcGIS Maps SDK for JavaScript 4.8FeaturesViewModel since 4.27, goToOverride added at 4.8. -
This function provides the ability to override either the MapView goTo() or SceneView goTo() methods.
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
InheritedPropertyhighlightEnabled Boolean
Inherited from FeaturesViewModelSince: ArcGIS Maps SDK for JavaScript 4.4FeaturesViewModel 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
InheritedPropertyincludeDefaultActions Boolean
Inherited from FeaturesViewModelSince: ArcGIS Maps SDK for JavaScript 4.19FeaturesViewModel 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
InheritedPropertylocation 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.
- See also
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
InheritedPropertymap Map
Inherited from FeaturesViewModelSince: ArcGIS Maps SDK for JavaScript 4.30FeaturesViewModel 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
InheritedPropertypendingPromisesCount Numberreadonly
Inherited from FeaturesViewModel -
The number of promises remaining to be resolved.
- Default Value:0
- See also
-
promiseCount
InheritedPropertypromiseCount Numberreadonly
Inherited from FeaturesViewModel -
The number of selected promises available.
- Default Value:0
-
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
InheritedPropertyselectedClusterBoundaryFeature Graphicreadonly
Inherited from FeaturesViewModelSince: ArcGIS Maps SDK for JavaScript 4.19FeaturesViewModel 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
InheritedPropertyselectedFeature Graphicreadonly
Inherited from FeaturesViewModel -
The selected feature accessed. The content is determined based on the PopupTemplate assigned to this feature.
-
selectedFeatureIndex
InheritedPropertyselectedFeatureIndex Number
Inherited from FeaturesViewModel -
Index of the feature that is selected. When features are set, the first index is automatically selected.
-
spatialReference
InheritedPropertyspatialReference SpatialReference
Inherited from FeaturesViewModelSince: ArcGIS Maps SDK for JavaScript 4.30FeaturesViewModel 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
InheritedPropertystate Stringreadonly
Inherited from FeaturesViewModel -
The view model's state.
Possible Values:"ready" |"disabled"
- Default Value:disabled
-
timeZone
InheritedPropertytimeZone String
Inherited from FeaturesViewModelSince: ArcGIS Maps SDK for JavaScript 4.30FeaturesViewModel 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
InheritedPropertytitle 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";
-
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:
- The features have a popupTemplate containing Arcade expressions in ExpressionInfo or ExpressionContent that may use geometry functions or reference the
$map
profile variable (i.e. access data from layers within a map). - Content is displayed from the popup template of an aggregate feature (i.e. a cluster or bin).
- Values from
date
andtimestamp-offset
fields should respect the view's time zone. - When using the
fetchFeatures
method or thefetchFeatures
option in theopen
method.
- The features have a popupTemplate containing Arcade expressions in ExpressionInfo or ExpressionContent that may use geometry functions or reference the
-
visible
InheritedPropertyvisible 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
InheritedPropertywaitingForResult Booleanreadonly
Inherited from FeaturesViewModelSince: ArcGIS Maps SDK for JavaScript 4.17FeaturesViewModel since 4.27, waitingForResult added at 4.17. -
Indicates whether a feature was found while resolving promises.
- Default Value:false
- See also
Method Overview
Name | Return Type | Summary | Class |
---|---|---|---|
Adds one or more handles which are to be tied to the lifecycle of the object. | Accessor | ||
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 | 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
-
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.
-
Inherited from FeaturesViewModel
-
-
emit
InheritedMethodemit(type, event){Boolean}
Inherited from FeaturesViewModelSince: ArcGIS Maps SDK for JavaScript 4.5FeaturesViewModel 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.
ReturnsType Description Boolean true
if a listener was notified
-
fetchFeatures
InheritedMethodfetchFeatures(screenPoint, options){Promise<FetchPopupFeaturesResult>}
Inherited from FeaturesViewModelSince: ArcGIS Maps SDK for JavaScript 4.15FeaturesViewModel 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.
ParametersReturnsType Description Promise<FetchPopupFeaturesResult> Resolves with the selected hitTest
location. In addition, it also returns an array of graphics if thehitTest
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
InheritedMethodhasEventListener(type){Boolean}
Inherited from FeaturesViewModel -
Indicates whether there is an event listener on the instance that matches the provided event name.
Parametertype StringThe name of the event.
ReturnsType Description Boolean Returns true if the class supports the input event.
-
hasHandles
InheritedMethodhasHandles(groupKey){Boolean}
Inherited from AccessorSince: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, hasHandles added at 4.25. -
Returns true if a named group of handles exist.
ParametergroupKey *optionalA group key.
ReturnsType Description Boolean Returns true
if a named group of handles exist.Example// Remove a named group of handles if they exist. if (obj.hasHandles("watch-view-updates")) { obj.removeHandles("watch-view-updates"); }
-
next
InheritedMethodnext(){FeaturesViewModel}
Inherited from FeaturesViewModel -
Selects the feature at the next index in relation to the selected feature.
ReturnsType Description FeaturesViewModel Returns an instance of the popup's view model. - See also
-
on
InheritedMethodon(type, listener){Object}
Inherited from FeaturesViewModel -
Registers an event handler on the instance. Call this method to hook an event with a listener.
ParametersReturnsType 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. Exampleview.on("click", function(event){ // event is the event handle returned after the event fires. console.log(event.mapPoint); });
-
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 totrue
. Users can alternatively set the visible property totrue
.ParametersSpecificationoptions ObjectoptionalDefines the location and content of the popup when opened.
Specificationtitle StringoptionalSets the title of the popup.
content StringoptionalSets the content of the popup.
fetchFeatures BooleanoptionalDefault Value: falseSince: 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 validview
andlocation
set.location PointoptionalSets the location, which is the geometry used to position the popup.
optional Sets the features, which populates the title and content based on each graphic's PopupTemplate.
optional Sets pending promises. The UI will display once the promises resolve. Each promise must resolve to an array of Graphics.
updateLocationEnabled BooleanoptionalDefault Value: falseWhen
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
InheritedMethodprevious(){FeaturesViewModel}
Inherited from FeaturesViewModel -
Selects the feature at the previous index in relation to the selected feature.
ReturnsType Description FeaturesViewModel Returns an instance of the popup's view model. - See also
-
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");
-
Inherited from FeaturesViewModel
-
Triggers the trigger-action event and executes the action at the specified index in the actions array.
Event Overview
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
-
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
-
action ActionButton|ActionToggle
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 }); } });