<?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: Adding an image to PopupTemplate V3.4 in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-an-image-to-popuptemplate-v3-4/m-p/1300741#M81436</link>
    <description>&lt;P&gt;Not sure, maybe you need to add your HTML to Content instead of Description?&lt;/P&gt;&lt;P&gt;I added a green button to this sample popup code from Esri:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;html lang="en"&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8" /&amp;gt;
    &amp;lt;meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /&amp;gt;
    &amp;lt;title&amp;gt;Popup actions | Sample | ArcGIS Maps SDK for JavaScript 4.27&amp;lt;/title&amp;gt;

    &amp;lt;style&amp;gt;
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }
    &amp;lt;/style&amp;gt;

    &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/4.27/esri/themes/light/main.css" /&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.27/"&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;script&amp;gt;
      require([
        "esri/Map",
        "esri/layers/FeatureLayer",
        "esri/views/MapView",
        "esri/geometry/geometryEngine",
        "esri/core/reactiveUtils"
      ], (Map, FeatureLayer, MapView, geometryEngine, reactiveUtils) =&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
        });

        /*************************************************************
         * 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: "&amp;lt;div&amp;gt;{name}&amp;lt;/div&amp;gt;&amp;lt;div class='popup-content'&amp;gt;&amp;lt;img src='https://w7.pngwing.com/pngs/714/342/png-transparent-computer-icons-button-green-green-3d-computer-graphics-grass-color-thumbnail.png' height='20px' alt='image description'&amp;gt;&amp;lt;/div&amp;gt;",
          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();
            }
          }
        );
      });
    &amp;lt;/script&amp;gt;
  &amp;lt;/head&amp;gt;

  &amp;lt;body&amp;gt;
    &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 19 Jun 2023 15:45:14 GMT</pubDate>
    <dc:creator>JeffreyWilkerson</dc:creator>
    <dc:date>2023-06-19T15:45:14Z</dc:date>
    <item>
      <title>Adding an image to PopupTemplate V3.4</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-an-image-to-popuptemplate-v3-4/m-p/1300588#M81430</link>
      <description>&lt;P&gt;Im trying to add an image to PopupTemplate in V3.4,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;doing something like this didn't work for me&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;return new PopupTemplate({
              title: `${event.mapPoint.x},  ${event.mapPoint.y}`,
              description:
                `&amp;lt;div class="popup-content"&amp;gt;` +
                "&amp;lt;img src='widgets/TowersConnection/images/Green-2G.png' alt='Image Description' " 

            });&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;i always get src empty in the browser so image never loads, how do i set an image then?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2023 02:15:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-an-image-to-popuptemplate-v3-4/m-p/1300588#M81430</guid>
      <dc:creator>HadiHoteit</dc:creator>
      <dc:date>2023-06-19T02:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: Adding an image to PopupTemplate V3.4</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-an-image-to-popuptemplate-v3-4/m-p/1300741#M81436</link>
      <description>&lt;P&gt;Not sure, maybe you need to add your HTML to Content instead of Description?&lt;/P&gt;&lt;P&gt;I added a green button to this sample popup code from Esri:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;html lang="en"&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8" /&amp;gt;
    &amp;lt;meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /&amp;gt;
    &amp;lt;title&amp;gt;Popup actions | Sample | ArcGIS Maps SDK for JavaScript 4.27&amp;lt;/title&amp;gt;

    &amp;lt;style&amp;gt;
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }
    &amp;lt;/style&amp;gt;

    &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/4.27/esri/themes/light/main.css" /&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.27/"&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;script&amp;gt;
      require([
        "esri/Map",
        "esri/layers/FeatureLayer",
        "esri/views/MapView",
        "esri/geometry/geometryEngine",
        "esri/core/reactiveUtils"
      ], (Map, FeatureLayer, MapView, geometryEngine, reactiveUtils) =&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
        });

        /*************************************************************
         * 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: "&amp;lt;div&amp;gt;{name}&amp;lt;/div&amp;gt;&amp;lt;div class='popup-content'&amp;gt;&amp;lt;img src='https://w7.pngwing.com/pngs/714/342/png-transparent-computer-icons-button-green-green-3d-computer-graphics-grass-color-thumbnail.png' height='20px' alt='image description'&amp;gt;&amp;lt;/div&amp;gt;",
          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();
            }
          }
        );
      });
    &amp;lt;/script&amp;gt;
  &amp;lt;/head&amp;gt;

  &amp;lt;body&amp;gt;
    &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 19 Jun 2023 15:45:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-an-image-to-popuptemplate-v3-4/m-p/1300741#M81436</guid>
      <dc:creator>JeffreyWilkerson</dc:creator>
      <dc:date>2023-06-19T15:45:14Z</dc:date>
    </item>
  </channel>
</rss>

