<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Popups in ArcGIS v4.23 vs 4.11 in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/popups-in-arcgis-v4-23-vs-4-11/m-p/1335132#M82400</link>
    <description>&lt;P&gt;Thank you, Sir!&amp;nbsp; That did it.&amp;nbsp; Appreciate the quick responses.&lt;/P&gt;</description>
    <pubDate>Wed, 04 Oct 2023 19:52:36 GMT</pubDate>
    <dc:creator>TimDietz</dc:creator>
    <dc:date>2023-10-04T19:52:36Z</dc:date>
    <item>
      <title>Popups in ArcGIS v4.23 vs 4.11</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/popups-in-arcgis-v4-23-vs-4-11/m-p/1331657#M82284</link>
      <description>&lt;P&gt;Our app contained the following code snippet when configured to use 4.11:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;popup.on('trigger-action', (event) =&amp;gt; {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; const featureLocation = this.mapView.toMap(event.target.screenLocation);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;We are now moving to 4.23 and the only event attribute is 'action', not 'target'. I can't quite figure out how to do it the new way. It looks like I might be able to do:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;event.action.get(&amp;lt;something&amp;gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;but I don't know what the equivalent to 'screenLocation' would be.&lt;/P&gt;&lt;P&gt;Can somebody help with this and either point me to where I might find the event.action object or paste the equivalent statement?&lt;/P&gt;&lt;P&gt;TIA.&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2023 20:39:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/popups-in-arcgis-v4-23-vs-4-11/m-p/1331657#M82284</guid>
      <dc:creator>TimDietz</dc:creator>
      <dc:date>2023-09-22T20:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: Popups in ArcGIS v4.23 vs 4.11</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/popups-in-arcgis-v4-23-vs-4-11/m-p/1331673#M82285</link>
      <description>&lt;P&gt;The event referred to in the trigger-action is the triggering of the popup action, not the standard browser click event.&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#event-trigger-action" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#event-trigger-action&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Since you have a popup open, you can use its selectedFeature property to get the get the geometry of the that the popup is connected to and then go to that map point. Something like...&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;mapView.goTo(popup.selectedFeature)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 22 Sep 2023 21:04:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/popups-in-arcgis-v4-23-vs-4-11/m-p/1331673#M82285</guid>
      <dc:creator>JeffreyThompson2</dc:creator>
      <dc:date>2023-09-22T21:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Popups in ArcGIS v4.23 vs 4.11</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/popups-in-arcgis-v4-23-vs-4-11/m-p/1331726#M82286</link>
      <description>&lt;P&gt;You can also do this as well:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;popup.on("trigger-action", function(target, event) {
	const featureLocation = target.location;
}.bind(this, popup));&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 22 Sep 2023 23:41:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/popups-in-arcgis-v4-23-vs-4-11/m-p/1331726#M82286</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2023-09-22T23:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: Popups in ArcGIS v4.23 vs 4.11</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/popups-in-arcgis-v4-23-vs-4-11/m-p/1335042#M82395</link>
      <description>&lt;P&gt;As an FYI, your example will not work.&amp;nbsp; I tried it and apparently, there is only one argument associated with the function and it is the event.&amp;nbsp; When I put the two in the console, the target param contained the same elements as an event, and the event param was null.&lt;/P&gt;&lt;P&gt;Still searching for a solution.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 17:16:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/popups-in-arcgis-v4-23-vs-4-11/m-p/1335042#M82395</guid>
      <dc:creator>TimDietz</dc:creator>
      <dc:date>2023-10-04T17:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: Popups in ArcGIS v4.23 vs 4.11</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/popups-in-arcgis-v4-23-vs-4-11/m-p/1335057#M82397</link>
      <description>&lt;P&gt;I've found it to be working properly.&amp;nbsp; In the &lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=popup-actions" target="_self"&gt;sandbox&lt;/A&gt; for the "Popup actions" sample, you can change the code in the script tag beginning on line 27 to the following:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;      require([
        "esri/Map",
        "esri/layers/FeatureLayer",
        "esri/views/MapView",
        "esri/geometry/geometryEngine",
        "esri/core/reactiveUtils",
        "esri/widgets/Popup"
      ], (Map, FeatureLayer, MapView, geometryEngine, reactiveUtils, Popup) =&amp;gt; {
        // Create the Map
        const map = new Map({
          basemap: "gray-vector"
        });

        // Create the MapView
        const view = new MapView({
          container: "viewDiv",
          map: map,
          center: [-117.08, 34.1],
          zoom: 11,
          popup: new Popup({})
        });

        /*************************************************************
         * The PopupTemplate content is the text that appears inside the
         * popup. Bracketed {fieldName} can be used to reference the value
         * of an attribute of the selected feature. HTML elements can be
         * used to provide structure and styles within the content.
         **************************************************************/

        // Add this action to the popup so it is always available in this view
        const measureThisAction = {
          title: "Measure Length",
          id: "measure-this",
          image:
            "https://developers.arcgis.com/javascript/latest/sample-code/popup-actions/live/Measure_Distance16.png"
        };

        const template = {
          // autocasts as new PopupTemplate()
          title: "Trail run",
          content: "{name}",
          actions: [measureThisAction]
        };

        const featureLayer = new FeatureLayer({
          url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/TrailRuns/FeatureServer/0",
          popupTemplate: template
        });

        map.add(featureLayer);

        // Execute each time the "Measure Length" is clicked
        function measureThis() {
          const geom = view.popup.selectedFeature.geometry;
          const initDistance = geometryEngine.geodesicLength(geom, "miles");
          const distance = parseFloat(
            Math.round(initDistance * 100) / 100
          ).toFixed(2);
          view.popup.content =
            view.popup.selectedFeature.attributes.name +
            "&amp;lt;div style='background-color:DarkGray;color:white'&amp;gt;" +
            distance +
            " miles.&amp;lt;/div&amp;gt;";
        }

        // Event handler that fires each time an action is clicked.
        reactiveUtils.on(
          () =&amp;gt; view.popup,
          "trigger-action",
          (event) =&amp;gt; {
            // Execute the measureThis() function if the measure-this action is clicked
            if (event.action.id === "measure-this") {
              measureThis();
            }
          }
        );

        view.popup.on("trigger-action", function(target, event) {
          const featureLocation = target.location;
          console.info(featureLocation.x + ", " + featureLocation.y);
          console.info(event.action.title);
          console.info(target);
          console.info(event);
        }.bind(this, view.popup));
      });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the code above, changes to the original are found on lines 6-8, 19-20, and (primarily) 77-84.&amp;nbsp; After the sample is refreshed, clicking on a feature and then the "Measure Length" action in the popup produces the following in the console, showing the expected output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="console.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/82303i26195AF3EED93F53/image-size/large?v=v2&amp;amp;px=999" role="button" title="console.png" alt="console.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If I had to guess as to why it isn't working for you, perhaps the call to &lt;A href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Function/bind" target="_self"&gt;bind&lt;/A&gt; was not made correctly.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 17:43:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/popups-in-arcgis-v4-23-vs-4-11/m-p/1335057#M82397</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2023-10-04T17:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: Popups in ArcGIS v4.23 vs 4.11</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/popups-in-arcgis-v4-23-vs-4-11/m-p/1335123#M82398</link>
      <description>&lt;P&gt;Thanks for the reply.&amp;nbsp; I believe your 'this' and my 'this' are two different object.&amp;nbsp; What does your 'this' refer to?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 19:27:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/popups-in-arcgis-v4-23-vs-4-11/m-p/1335123#M82398</guid>
      <dc:creator>TimDietz</dc:creator>
      <dc:date>2023-10-04T19:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: Popups in ArcGIS v4.23 vs 4.11</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/popups-in-arcgis-v4-23-vs-4-11/m-p/1335125#M82399</link>
      <description>&lt;P&gt;In the case of the sample, "this" will refer to the window object since that's the context in which the call to bind occurs.&amp;nbsp; Whatever you pass in the first argument of the bind function will be whatever "this" refers to inside the bound function.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 19:35:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/popups-in-arcgis-v4-23-vs-4-11/m-p/1335125#M82399</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2023-10-04T19:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: Popups in ArcGIS v4.23 vs 4.11</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/popups-in-arcgis-v4-23-vs-4-11/m-p/1335132#M82400</link>
      <description>&lt;P&gt;Thank you, Sir!&amp;nbsp; That did it.&amp;nbsp; Appreciate the quick responses.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 19:52:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/popups-in-arcgis-v4-23-vs-4-11/m-p/1335132#M82400</guid>
      <dc:creator>TimDietz</dc:creator>
      <dc:date>2023-10-04T19:52:36Z</dc:date>
    </item>
  </channel>
</rss>

