<?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: How to add generic popup templates for all FeatureLayers in all MapImageLayers in a map in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-generic-popup-templates-for-all/m-p/1622903#M87251</link>
    <description>&lt;P&gt;Thank you UndralBatsukh, your solution is much more straight forward than mine.&amp;nbsp; I edited my original post but this is much better!&lt;/P&gt;</description>
    <pubDate>Wed, 11 Jun 2025 22:30:37 GMT</pubDate>
    <dc:creator>PeterK</dc:creator>
    <dc:date>2025-06-11T22:30:37Z</dc:date>
    <item>
      <title>How to add generic popup templates for all FeatureLayers in all MapImageLayers in a map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-generic-popup-templates-for-all/m-p/1622760#M87242</link>
      <description>&lt;P&gt;Not a question but hopefully this will help someone who was struggling with the same issue.&amp;nbsp; The code below will add generic popupTemplates for all FeatureLayers in all MapImageLayers in a map.&amp;nbsp; This code should be run after you have added all of your layers to a map.&amp;nbsp; If someone can figure out how to expand this to include RasterLayers (if that is possible) that would be fantastic.&amp;nbsp; Since I'm still in the learning phase, any improvements or feedback would be appreciated.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;require([
    "esri/config"
    , "esri/Map"
    , "esri/views/MapView"
    , "esri/layers/ImageryLayer"
    , "esri/layers/FeatureLayer"
    , "esri/identity/IdentityManager"
    , "esri/layers/MapImageLayer"
    , "esri/support/actions/ActionButton"
    , "esri/core/Collection"
    , "esri/geometry/Extent"
    , "esri/Basemap"]
    , function (
        esriConfig
        , Map
        , MapView
        , ImageryLayer
        , FeatureLayer
        , esriId
        , MapImageLayer
        , ActionButton
        , Collection
        , Extent
        , identify
        , IdentifyParameters
        , PopupTemplate
        , FieldInfo
        , Basemap
    ) {

        const arcgisMap = document.querySelector("arcgis-map");

        arcgisMap.addEventListener("arcgisViewReadyChange", (event) =&amp;gt; {
            arcgisMap.map.addMany(['Add you MapImageLayers here...']);

            arcgisMap.map.layers.map(layer =&amp;gt; {
                layer.load().then(function (layer) {
                    layer.sublayers.forEach(sublayer =&amp;gt; {
                        sublayer.load().then(function (loadedSubLayer) {
                            var template = { type: "fields", fieldInfos: [] };
                            if (loadedSubLayer.fields != null) {
                                loadedSubLayer.fields.forEach((field) =&amp;gt; {
                                    if (field.name.toLowerCase() != 'shape') {
                                        template.fieldInfos.push({ fieldName: field.name, label: field.name, isEditable: false, tooltip: "", visible: true, format: null, stringFieldOption: "text-box" });
                                    }
                                });
                                loadedSubLayer.popupEnabled = true;
                                loadedSubLayer.popupTemplate = {
                                    title: layer.title + ': ' + loadedSubLayer.title,
                                    content: [template]
                                }
                            }
                        });
                    });
                });
            });
        });
    });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2025 22:22:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-generic-popup-templates-for-all/m-p/1622760#M87242</guid>
      <dc:creator>PeterK</dc:creator>
      <dc:date>2025-06-11T22:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to add generic popup templates for all FeatureLayers in all MapImageLayers in a map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-generic-popup-templates-for-all/m-p/1622762#M87243</link>
      <description>&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#defaultPopupTemplateEnabled" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#defaultPopupTemplateEnabled&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Maybe you missed the defaultPopupTemplateEnabled property?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2025 17:44:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-generic-popup-templates-for-all/m-p/1622762#M87243</guid>
      <dc:creator>JeffreyThompson2</dc:creator>
      <dc:date>2025-06-11T17:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to add generic popup templates for all FeatureLayers in all MapImageLayers in a map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-generic-popup-templates-for-all/m-p/1622777#M87244</link>
      <description>&lt;P&gt;Couldn't figure out how to do that for all FeatureLayers inside a MapImageLayer.&amp;nbsp; If you have an example I would appreciate it.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2025 17:52:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-generic-popup-templates-for-all/m-p/1622777#M87244</guid>
      <dc:creator>PeterK</dc:creator>
      <dc:date>2025-06-11T17:52:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to add generic popup templates for all FeatureLayers in all MapImageLayers in a map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-generic-popup-templates-for-all/m-p/1622787#M87245</link>
      <description>&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#popupTemplate" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#popupTemplate&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Any layer that does not have a defined popupTemplate should automatically get a default popup with defaultPopupTemplateEnabled = true.&amp;nbsp;&lt;/P&gt;&lt;P&gt;To answer your question: Raster layers do not support popups at all.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2025 18:06:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-generic-popup-templates-for-all/m-p/1622787#M87245</guid>
      <dc:creator>JeffreyThompson2</dc:creator>
      <dc:date>2025-06-11T18:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to add generic popup templates for all FeatureLayers in all MapImageLayers in a map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-generic-popup-templates-for-all/m-p/1622802#M87246</link>
      <description>&lt;P&gt;Thank you for the reply.&amp;nbsp; In the online reference, it does not show any property or method for Popups for MapImageLayer.&amp;nbsp; &amp;nbsp;My map has only MapImageLayers in it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this and it didn't work:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;arcgisMap.view.popup.defaultPopupTemplateEnabled = true;

arcgisMap.map.layers.map(layer =&amp;gt; {
    layer.when(() =&amp;gt; {
        var mapFeatureLayers = [];
        layer.sourceJSON.layers.forEach((sublayer) =&amp;gt; {
            if (sublayer.type == 'Feature Layer') {
                sublayer.popupEnabled = true;
            }
        });
    })
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For ImageryLayers, I do see references to popups so I'm not sure how that would work with those types of layers.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2025 18:29:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-generic-popup-templates-for-all/m-p/1622802#M87246</guid>
      <dc:creator>PeterK</dc:creator>
      <dc:date>2025-06-11T18:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to add generic popup templates for all FeatureLayers in all MapImageLayers in a map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-generic-popup-templates-for-all/m-p/1622828#M87247</link>
      <description>&lt;P&gt;Looking at your code, I think your fundamental problem may have been not loading the Popup module. Calling this should be all you need to do:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;arcgisMap.popup = new Popup({
    defaultPopupTemplateEnabled: true
})&lt;/LI-CODE&gt;&lt;P&gt;Additionally, the type for a subtype is always 'subtype', so the if statement above will never be entered.&lt;/P&gt;&lt;P&gt;Yes, it is possible to have popups on a ImageryLayer, but I don't know enough about them to say what you need to do to make them work.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2025 19:54:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-generic-popup-templates-for-all/m-p/1622828#M87247</guid>
      <dc:creator>JeffreyThompson2</dc:creator>
      <dc:date>2025-06-11T19:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to add generic popup templates for all FeatureLayers in all MapImageLayers in a map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-generic-popup-templates-for-all/m-p/1622860#M87248</link>
      <description>&lt;P&gt;Thank you for your response.&amp;nbsp; What you reference in your last post works fine if I have added a FeatureLayer to the map but not for a MapImageLayer.&lt;/P&gt;&lt;P&gt;On the link you posted above (&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#defaultPopupTemplateEnabled)" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#defaultPopupTemplateEnabled)&lt;/A&gt;&amp;nbsp;it says this about the layers that are supported, it doesn't mention MapImageLayers:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"Supported for &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html" target="_blank"&gt;FeatureLayer&lt;/A&gt;, &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoJSONLayer.html" target="_blank"&gt;GeoJSONLayer&lt;/A&gt;, &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-OGCFeatureLayer.html" target="_blank"&gt;OGCFeatureLayer&lt;/A&gt;, &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html" target="_blank"&gt;SceneLayer&lt;/A&gt;, &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html" target="_blank"&gt;CSVLayer&lt;/A&gt;, &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html" target="_blank"&gt;PointCloudLayer&lt;/A&gt;, &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html" target="_blank"&gt;StreamLayer&lt;/A&gt;, &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html" target="_blank"&gt;ImageryLayer&lt;/A&gt;, and &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VoxelLayer.html" target="_blank"&gt;VoxelLayer"&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I was able to get the popup working for an ImageryLayer but not for Raster Layers embedded in a MapImageLayer.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2025 20:44:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-generic-popup-templates-for-all/m-p/1622860#M87248</guid>
      <dc:creator>PeterK</dc:creator>
      <dc:date>2025-06-11T20:44:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to add generic popup templates for all FeatureLayers in all MapImageLayers in a map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-generic-popup-templates-for-all/m-p/1622900#M87250</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;You need to load all sublayers from the MapImageLayer by calling &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html#loadAll" target="_self"&gt;loadAll()&lt;/A&gt; on the MapImageLayer instance as shown below:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;layer.loadAll().then(() =&amp;gt; {
  layer.sublayers.map((sublayer) =&amp;gt; {
    sublayer.popupTemplate = sublayer.createPopupTemplate();
  });
 });&lt;/LI-CODE&gt;&lt;P&gt;This codepen shows how to setup popupTemplate for sublayers -&amp;nbsp;&lt;A href="https://codepen.io/U_B_U/pen/QwbrLXO?editors=100" target="_blank"&gt;https://codepen.io/U_B_U/pen/QwbrLXO?editors=100&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;-Undral&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2025 22:25:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-generic-popup-templates-for-all/m-p/1622900#M87250</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2025-06-11T22:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to add generic popup templates for all FeatureLayers in all MapImageLayers in a map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-generic-popup-templates-for-all/m-p/1622903#M87251</link>
      <description>&lt;P&gt;Thank you UndralBatsukh, your solution is much more straight forward than mine.&amp;nbsp; I edited my original post but this is much better!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2025 22:30:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-generic-popup-templates-for-all/m-p/1622903#M87251</guid>
      <dc:creator>PeterK</dc:creator>
      <dc:date>2025-06-11T22:30:37Z</dc:date>
    </item>
  </channel>
</rss>

