You are using a browser that is no longer supported. Please use the latest version of Google Chrome, Mozilla Firefox, Apple Safari, or Microsoft Edge. For more information please see the System Requirements.
Skip To ContentArcGIS for DevelopersSign In Dashboard

Unsupported browser

You are using a browser that is not supported. JavaScript API works on the latest versions of Google Chrome, Mozilla Firefox, Apple Safari, or Microsoft Edge. Use one of these browsers and provide your feedback through GeoNet, the Esri Community.

  • {}
  • Firefox
  • Safari
  • undefined

Note: Support for 3D on mobile devices may vary, view the system requirements for more information.

The Popup widget may contain one or more actions, or buttons, that allow users to execute a function when clicked. The default popup on the view contains an "Zoom in" action that is symbolized by a magnifying glass icon zoom-action. When clicked, the view zooms in four LODs for points or to the extent of the feature for non-points, and centers on the selected feature.

This sample demonstrates how to add custom actions to a Popup and a PopupTemplate. Actions are added via the actions property on either Popup or PopupTemplate. Actions are added to the popup in the order they are added to the actions array.

Actions are styled by either using the class or image property. If using class, you must use an icon font. If using image, you must provide a valid URL to an image that will be used as a background-image for the action. Examples of both are used in this sample.

// Add this action to the popup so it is always available in this view
var measureThisAction = {
  title: "Measure Length",
  id: "measure-this",
  image: "Measure_Distance16.png"

var template = {
  // autocasts as new PopupTemplate()
  title: "Trail run",
  content: "{name}",
  actions: [measureThisAction]

featureLayer = new FeatureLayer({
  url: "",
  outFields: ["*"],
  popupTemplate: template // Set the popupTemplate with the actions set above


// Execute each time the "Measure Length" is clicked
function measureThis() {
  var geom = view.popup.selectedFeature.geometry;
  var distance = geometryEngine.geodesicLength(geom, "miles");
  distance = parseFloat(Math.round(distance * 100) / 100).toFixed(2);
  view.popup.content = +
    "<div style='background-color:DarkGray;color:white'>" +
    distance +
    " miles.</div>";

// Event handler that fires each time an action is clicked.
view.popup.on("trigger-action", function(event) {
  // Execute the measureThis() function if the measure-this action is clicked
  if ( === "measure-this") {

Sample search results