<?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 Get underlying object id graphics in cluster + programmatically display feature reduction pop up template with custom content in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-underlying-object-id-graphics-in-cluster/m-p/1006969#M71002</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;My requirements:&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Get the underlying features in object ids from a cluster graphic. E.g. if cluster A have 5 features, get all 5 object ids when user clicks on it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Pass that object id&lt;SPAN&gt;s as parameters into a custom content widget that will display fields relating to those 5 features in a pop up. The custom content widget will serves as the content for a new pop up template.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3. Display the pop up template when the user clicks on a cluster.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Conclusion, when user clicks on cluster A with 5 features inside the cluster, a pop up opens that displays field X,Y,Z for each features.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Solution thus far :&lt;BR /&gt;&lt;BR /&gt;1. Create a graphics layer and add to view&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Create a listener for 'clicks' on the view&lt;/P&gt;&lt;P&gt;3. Pass the event of that listener to a hitTest that includes the feature layer&amp;nbsp;&lt;/P&gt;&lt;P&gt;4. Get the graphic of the cluster&amp;nbsp;&lt;/P&gt;&lt;P&gt;5. Create a geodesicBuffer based on the graphic geometry with an approximate size. &lt;STRONG&gt;[Question!!! Is there a way to match the size of the cluster graphics with the input options for geodesicBuffer? ]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;6. Add a new graphic to the graphics layer with geometry as the geodesicBuffer&lt;/P&gt;&lt;P&gt;7. Query object ids on the feature layer by passing the geometry of the first graphic in the graphics layer, and defining a spatial relationship of intersect&lt;/P&gt;&lt;P&gt;8. The result should return an array of object ids&amp;nbsp;&lt;/P&gt;&lt;P&gt;9. Create a new CustomContent class and pass the object ids as an argument into creator method, to display the array of object ids in a div element&lt;/P&gt;&lt;P&gt;10. Create a new PopupTemplate class and pass the custom content created at #9 as content&amp;nbsp;&lt;/P&gt;&lt;P&gt;11. Remove all graphics from the graphics layer&lt;/P&gt;&lt;P&gt;12. Set the featurelayer.featureReduction.popupTemplate to be equal to the newly created pop up template at #10.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Problems:&lt;/P&gt;&lt;P&gt;1. Because the featurelayer.featureReduction.popupTemplate is only after the click is pressed, and pop up templates are to display be default with a click. What I observe is that the pop up will initially display the previous object ids. Once the user clicks on the same cluster again, the&amp;nbsp;featurelayer.featureReduction.popupTemplate is updated, and now the user will see the correct object ids in the pop up.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, user clicks on cluster A with object ids [1,2,3], the pop up displays [1,2,3]. When user clicks on cluster B with object ids [4,5,6], the pop up displays [1,2,3], when the user clicks on cluster B again, the pop up displays [4,5,6]&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Question!! : Is there a way to override the default option of the pop up displaying? Much like programmatically turning the pop up on a view.. I do not see an equivalent&amp;nbsp;for pop up templates.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;2. Is there a way to create a graphic layers that is a copy of the clustered feature layer? Being able to do so would mean that I can create the graphics that reflects the cluster graphic in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have modified a sample to reflect my problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;html&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;!--
  ArcGIS API for JavaScript, https://js.arcgis.com
  For more information about the featurereduction-cluster-filter sample, read the original sample description at developers.arcgis.com.
  https://developers.arcgis.com/javascript/latest/sample-code/featurereduction-cluster-filter/index.html
  --&amp;gt;
    &amp;lt;title&amp;gt;
      Point clustering - generate suggested configuration | Sample | ArcGIS API
      for JavaScript 4.17
    &amp;lt;/title&amp;gt;

    &amp;lt;link
      rel="stylesheet"
      href="https://js.arcgis.com/4.17/esri/themes/light/main.css"
    /&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.17/"&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;style&amp;gt;
      html,
      body,
      #viewDiv {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
      }
      #infoDiv {
        background: white;
        padding: 10px;
      }
    &amp;lt;/style&amp;gt;

    &amp;lt;script&amp;gt;
      require([
        "esri/WebMap",
        "esri/views/MapView",
        "esri/layers/FeatureLayer",
        "esri/widgets/Legend",
        "esri/widgets/Expand",
        "esri/smartMapping/labels/clusters",
        "esri/smartMapping/popup/clusters",
        "esri/core/promiseUtils",
        "esri/geometry/geometryEngine",
        "esri/layers/GraphicsLayer",
        "esri/Graphic",
        "esri/PopupTemplate",
        "esri/popup/content/CustomContent",
      ], function (
        Map,
        MapView,
        FeatureLayer,
        Legend,
        Expand,
        clusterLabelCreator,
        clusterPopupCreator,
        promiseUtils,
        geometryEngine,
        GraphicsLayer,
        Graphic,
        PopupTemplate,
        CustomContent
      ) {
        const serviceUrl =
          "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Places_of_Worship_India/FeatureServer/0";
        const layer = new FeatureLayer({
          url: serviceUrl,
          title: "Places of worship",
          outFields: ["name", "religion", "denomination"],
          popupTemplate: {
            title: "{name}",
            content: [
              {
                type: "fields",
                fieldInfos: [
                  {
                    fieldName: "religion",
                  },
                  {
                    fieldName: "denomination",
                  },
                ],
              },
            ],
          },
        });

        const map = new Map({
          basemap: "gray-vector",
          layers: [layer],
        });

        const view = new MapView({
          container: "viewDiv",
          map: map,
          center: [80.20127, 22.12355],
          zoom: 4,
        });

        const legend = new Legend({
          view: view,
          container: "legendDiv",
        });

        const infoDiv = document.getElementById("infoDiv");
        view.ui.add(
          new Expand({
            view: view,
            content: infoDiv,
            expandIconClass: "esri-icon-layer-list",
            expanded: true,
          }),
          "top-right"
        );

        view.on("click", function () {
          layer
            .when()
            .then(generateClusterConfig)
            .then(function (featureReduction) {
              layer.featureReduction = featureReduction;

              console.log("layer", layer);

              const toggleButton = document.getElementById("toggle-cluster");
              toggleButton.addEventListener("click", toggleClustering);

              // To turn off clustering on a layer, set the
              // featureReduction property to null
              function toggleClustering() {
                if (isWithinScaleThreshold()) {
                  let fr = layer.featureReduction;
                  layer.featureReduction =
                    fr &amp;amp;&amp;amp; fr.type === "cluster" ? null : featureReduction;
                }
                toggleButton.innerText =
                  toggleButton.innerText === "Enable Clustering"
                    ? "Disable Clustering"
                    : "Enable Clustering";
              }

              view.whenLayerView(layer).then(function (layerView) {
                const filterSelect = document.getElementById("filter");
                // filters the layer using a definitionExpression
                // based on a religion selected by the user
                filterSelect.addEventListener("change", function (event) {
                  const newValue = event.target.value;

                  const whereClause = newValue
                    ? "religion = '" + newValue + "'"
                    : null;
                  layerView.filter = {
                    where: whereClause,
                  };
                  // close popup for former cluster that no longer displays
                  view.popup.close();
                });
              });

              view.watch("scale", function (scale) {
                if (toggleButton.innerText === "Disable Clustering") {
                  layer.featureReduction = isWithinScaleThreshold()
                    ? featureReduction
                    : null;
                }
              });
            })

            .catch(function (error) {
              console.error(error);
            });
        });

        function isWithinScaleThreshold() {
          return view.scale &amp;gt; 50000;
        }

        let bufferLayer = new GraphicsLayer();
        let customPopupTemplate;

        view.map.add(bufferLayer);

        function generateClusterConfig(layer) {
          view.on("click", function (e) {
            view.hitTest(e, { include: layer }).then(function (res) {
              //   console.log("res", res);

              if (res.results.length) {
                var graphic = res.results[0].graphic;

                console.log("graphic:", graphic);

                var buffer = geometryEngine.geodesicBuffer(
                  graphic.geometry,
                  50,
                  "kilometers"
                );
                bufferLayer.add(
                  new Graphic({
                    geometry: buffer,
                    symbol: {
                      type: "simple-fill", // autocasts as new SimpleFillSymbol()
                      color: "black",
                      outline: {
                        color: [0, 0, 0, 0.5],
                        width: 2,
                      },
                    },
                  })
                );

                // console.log("bufferLayer", bufferLayer);
                let popupEnabled;
                layer
                  .queryObjectIds({
                    geometry: bufferLayer.graphics.getItemAt(0).geometry,
                    spatialRelationship: "intersects",
                    returnGeometry: false,
                    outFields: ["*"],
                  })
                  .then(function (objectIds) {
                    // console.log(objectIds);
                    if (!objectIds.length) {
                      //   console.log("no object ids");
                      return;
                    } else {
                      const array = objectIds;

                      // This custom content returns a promise
                      let customContentWidget = new CustomContent({
                        outFields: ["*"],
                        creator: function (objectIds) {
                          const div = document.createElement("div");
                          //   console.log("array", array);
                          div.innerHTML = array.join(",");
                          return div;
                        },
                      });

                      customPopupTemplate = new PopupTemplate({
                        outFields: ["*"],
                        content: [customContentWidget],
                      });

                      bufferLayer.removeAll();

                      return {
                        type: "cluster",
                        popupTemplate: customPopupTemplate,
                        popupEnabled: popupEnabled,
                        labelingInfo: {
                          deconflictionStrategy: "none",

                          symbol: {
                            type: "text",
                            color: "#004a5d",
                            font: {
                              weight: "bold",
                              family: "Noto Sans",
                              size: 12,
                            },
                            xoffset: 0,
                            yoffset: -15,
                          },
                          labelPlacement: "center-center",
                          labelExpressionInfo: {
                            expression:
                              "Text($feature.cluster_count, '#,### plays')",
                          },
                        },
                        clusterMinSize: 20,
                      };
                    }
                  });

                // view.popup.open();
              }
            });
          });

          console.log("customPopupTemplate", customPopupTemplate);

          // generates default popupTemplate
          return {
            type: "cluster",
            popupTemplate: customPopupTemplate,
            labelingInfo: {
              deconflictionStrategy: "none",

              symbol: {
                type: "text",
                color: "#004a5d",
                font: {
                  weight: "bold",
                  family: "Noto Sans",
                  size: 12,
                },
                xoffset: 0,
                yoffset: -15,
              },
              labelPlacement: "center-center",
              labelExpressionInfo: {
                expression: "Text($feature.cluster_count, '#,### plays')",
              },
            },
            clusterMinSize: 20,
          };
        }
      });
    &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;div id="infoDiv" class="esri-widget"&amp;gt;
      Filter by religion:
      &amp;lt;select id="filter" class="esri-select"&amp;gt;
        &amp;lt;option value=""&amp;gt;All&amp;lt;/option&amp;gt;
        &amp;lt;option value="Hindu"&amp;gt;Hindu&amp;lt;/option&amp;gt;
        &amp;lt;option value="Christian"&amp;gt;Christian&amp;lt;/option&amp;gt;
        &amp;lt;option value="Muslim"&amp;gt;Muslim&amp;lt;/option&amp;gt;
        &amp;lt;option value="Buddhist"&amp;gt;Buddhist&amp;lt;/option&amp;gt;
        &amp;lt;option value="Sikh"&amp;gt;Sikh&amp;lt;/option&amp;gt;
        &amp;lt;option value="Jain"&amp;gt;Jain&amp;lt;/option&amp;gt;
      &amp;lt;/select&amp;gt;
      &amp;lt;div style="padding-top: 10px"&amp;gt;
        &amp;lt;button id="toggle-cluster" class="esri-button"&amp;gt;
          Disable Clustering
        &amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;div id="legendDiv"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Dec 2020 15:27:53 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2020-12-04T15:27:53Z</dc:date>
    <item>
      <title>Get underlying object id graphics in cluster + programmatically display feature reduction pop up template with custom content</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-underlying-object-id-graphics-in-cluster/m-p/1006969#M71002</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;My requirements:&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Get the underlying features in object ids from a cluster graphic. E.g. if cluster A have 5 features, get all 5 object ids when user clicks on it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Pass that object id&lt;SPAN&gt;s as parameters into a custom content widget that will display fields relating to those 5 features in a pop up. The custom content widget will serves as the content for a new pop up template.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3. Display the pop up template when the user clicks on a cluster.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Conclusion, when user clicks on cluster A with 5 features inside the cluster, a pop up opens that displays field X,Y,Z for each features.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Solution thus far :&lt;BR /&gt;&lt;BR /&gt;1. Create a graphics layer and add to view&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Create a listener for 'clicks' on the view&lt;/P&gt;&lt;P&gt;3. Pass the event of that listener to a hitTest that includes the feature layer&amp;nbsp;&lt;/P&gt;&lt;P&gt;4. Get the graphic of the cluster&amp;nbsp;&lt;/P&gt;&lt;P&gt;5. Create a geodesicBuffer based on the graphic geometry with an approximate size. &lt;STRONG&gt;[Question!!! Is there a way to match the size of the cluster graphics with the input options for geodesicBuffer? ]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;6. Add a new graphic to the graphics layer with geometry as the geodesicBuffer&lt;/P&gt;&lt;P&gt;7. Query object ids on the feature layer by passing the geometry of the first graphic in the graphics layer, and defining a spatial relationship of intersect&lt;/P&gt;&lt;P&gt;8. The result should return an array of object ids&amp;nbsp;&lt;/P&gt;&lt;P&gt;9. Create a new CustomContent class and pass the object ids as an argument into creator method, to display the array of object ids in a div element&lt;/P&gt;&lt;P&gt;10. Create a new PopupTemplate class and pass the custom content created at #9 as content&amp;nbsp;&lt;/P&gt;&lt;P&gt;11. Remove all graphics from the graphics layer&lt;/P&gt;&lt;P&gt;12. Set the featurelayer.featureReduction.popupTemplate to be equal to the newly created pop up template at #10.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Problems:&lt;/P&gt;&lt;P&gt;1. Because the featurelayer.featureReduction.popupTemplate is only after the click is pressed, and pop up templates are to display be default with a click. What I observe is that the pop up will initially display the previous object ids. Once the user clicks on the same cluster again, the&amp;nbsp;featurelayer.featureReduction.popupTemplate is updated, and now the user will see the correct object ids in the pop up.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, user clicks on cluster A with object ids [1,2,3], the pop up displays [1,2,3]. When user clicks on cluster B with object ids [4,5,6], the pop up displays [1,2,3], when the user clicks on cluster B again, the pop up displays [4,5,6]&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Question!! : Is there a way to override the default option of the pop up displaying? Much like programmatically turning the pop up on a view.. I do not see an equivalent&amp;nbsp;for pop up templates.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;2. Is there a way to create a graphic layers that is a copy of the clustered feature layer? Being able to do so would mean that I can create the graphics that reflects the cluster graphic in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have modified a sample to reflect my problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;html&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;!--
  ArcGIS API for JavaScript, https://js.arcgis.com
  For more information about the featurereduction-cluster-filter sample, read the original sample description at developers.arcgis.com.
  https://developers.arcgis.com/javascript/latest/sample-code/featurereduction-cluster-filter/index.html
  --&amp;gt;
    &amp;lt;title&amp;gt;
      Point clustering - generate suggested configuration | Sample | ArcGIS API
      for JavaScript 4.17
    &amp;lt;/title&amp;gt;

    &amp;lt;link
      rel="stylesheet"
      href="https://js.arcgis.com/4.17/esri/themes/light/main.css"
    /&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.17/"&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;style&amp;gt;
      html,
      body,
      #viewDiv {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
      }
      #infoDiv {
        background: white;
        padding: 10px;
      }
    &amp;lt;/style&amp;gt;

    &amp;lt;script&amp;gt;
      require([
        "esri/WebMap",
        "esri/views/MapView",
        "esri/layers/FeatureLayer",
        "esri/widgets/Legend",
        "esri/widgets/Expand",
        "esri/smartMapping/labels/clusters",
        "esri/smartMapping/popup/clusters",
        "esri/core/promiseUtils",
        "esri/geometry/geometryEngine",
        "esri/layers/GraphicsLayer",
        "esri/Graphic",
        "esri/PopupTemplate",
        "esri/popup/content/CustomContent",
      ], function (
        Map,
        MapView,
        FeatureLayer,
        Legend,
        Expand,
        clusterLabelCreator,
        clusterPopupCreator,
        promiseUtils,
        geometryEngine,
        GraphicsLayer,
        Graphic,
        PopupTemplate,
        CustomContent
      ) {
        const serviceUrl =
          "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Places_of_Worship_India/FeatureServer/0";
        const layer = new FeatureLayer({
          url: serviceUrl,
          title: "Places of worship",
          outFields: ["name", "religion", "denomination"],
          popupTemplate: {
            title: "{name}",
            content: [
              {
                type: "fields",
                fieldInfos: [
                  {
                    fieldName: "religion",
                  },
                  {
                    fieldName: "denomination",
                  },
                ],
              },
            ],
          },
        });

        const map = new Map({
          basemap: "gray-vector",
          layers: [layer],
        });

        const view = new MapView({
          container: "viewDiv",
          map: map,
          center: [80.20127, 22.12355],
          zoom: 4,
        });

        const legend = new Legend({
          view: view,
          container: "legendDiv",
        });

        const infoDiv = document.getElementById("infoDiv");
        view.ui.add(
          new Expand({
            view: view,
            content: infoDiv,
            expandIconClass: "esri-icon-layer-list",
            expanded: true,
          }),
          "top-right"
        );

        view.on("click", function () {
          layer
            .when()
            .then(generateClusterConfig)
            .then(function (featureReduction) {
              layer.featureReduction = featureReduction;

              console.log("layer", layer);

              const toggleButton = document.getElementById("toggle-cluster");
              toggleButton.addEventListener("click", toggleClustering);

              // To turn off clustering on a layer, set the
              // featureReduction property to null
              function toggleClustering() {
                if (isWithinScaleThreshold()) {
                  let fr = layer.featureReduction;
                  layer.featureReduction =
                    fr &amp;amp;&amp;amp; fr.type === "cluster" ? null : featureReduction;
                }
                toggleButton.innerText =
                  toggleButton.innerText === "Enable Clustering"
                    ? "Disable Clustering"
                    : "Enable Clustering";
              }

              view.whenLayerView(layer).then(function (layerView) {
                const filterSelect = document.getElementById("filter");
                // filters the layer using a definitionExpression
                // based on a religion selected by the user
                filterSelect.addEventListener("change", function (event) {
                  const newValue = event.target.value;

                  const whereClause = newValue
                    ? "religion = '" + newValue + "'"
                    : null;
                  layerView.filter = {
                    where: whereClause,
                  };
                  // close popup for former cluster that no longer displays
                  view.popup.close();
                });
              });

              view.watch("scale", function (scale) {
                if (toggleButton.innerText === "Disable Clustering") {
                  layer.featureReduction = isWithinScaleThreshold()
                    ? featureReduction
                    : null;
                }
              });
            })

            .catch(function (error) {
              console.error(error);
            });
        });

        function isWithinScaleThreshold() {
          return view.scale &amp;gt; 50000;
        }

        let bufferLayer = new GraphicsLayer();
        let customPopupTemplate;

        view.map.add(bufferLayer);

        function generateClusterConfig(layer) {
          view.on("click", function (e) {
            view.hitTest(e, { include: layer }).then(function (res) {
              //   console.log("res", res);

              if (res.results.length) {
                var graphic = res.results[0].graphic;

                console.log("graphic:", graphic);

                var buffer = geometryEngine.geodesicBuffer(
                  graphic.geometry,
                  50,
                  "kilometers"
                );
                bufferLayer.add(
                  new Graphic({
                    geometry: buffer,
                    symbol: {
                      type: "simple-fill", // autocasts as new SimpleFillSymbol()
                      color: "black",
                      outline: {
                        color: [0, 0, 0, 0.5],
                        width: 2,
                      },
                    },
                  })
                );

                // console.log("bufferLayer", bufferLayer);
                let popupEnabled;
                layer
                  .queryObjectIds({
                    geometry: bufferLayer.graphics.getItemAt(0).geometry,
                    spatialRelationship: "intersects",
                    returnGeometry: false,
                    outFields: ["*"],
                  })
                  .then(function (objectIds) {
                    // console.log(objectIds);
                    if (!objectIds.length) {
                      //   console.log("no object ids");
                      return;
                    } else {
                      const array = objectIds;

                      // This custom content returns a promise
                      let customContentWidget = new CustomContent({
                        outFields: ["*"],
                        creator: function (objectIds) {
                          const div = document.createElement("div");
                          //   console.log("array", array);
                          div.innerHTML = array.join(",");
                          return div;
                        },
                      });

                      customPopupTemplate = new PopupTemplate({
                        outFields: ["*"],
                        content: [customContentWidget],
                      });

                      bufferLayer.removeAll();

                      return {
                        type: "cluster",
                        popupTemplate: customPopupTemplate,
                        popupEnabled: popupEnabled,
                        labelingInfo: {
                          deconflictionStrategy: "none",

                          symbol: {
                            type: "text",
                            color: "#004a5d",
                            font: {
                              weight: "bold",
                              family: "Noto Sans",
                              size: 12,
                            },
                            xoffset: 0,
                            yoffset: -15,
                          },
                          labelPlacement: "center-center",
                          labelExpressionInfo: {
                            expression:
                              "Text($feature.cluster_count, '#,### plays')",
                          },
                        },
                        clusterMinSize: 20,
                      };
                    }
                  });

                // view.popup.open();
              }
            });
          });

          console.log("customPopupTemplate", customPopupTemplate);

          // generates default popupTemplate
          return {
            type: "cluster",
            popupTemplate: customPopupTemplate,
            labelingInfo: {
              deconflictionStrategy: "none",

              symbol: {
                type: "text",
                color: "#004a5d",
                font: {
                  weight: "bold",
                  family: "Noto Sans",
                  size: 12,
                },
                xoffset: 0,
                yoffset: -15,
              },
              labelPlacement: "center-center",
              labelExpressionInfo: {
                expression: "Text($feature.cluster_count, '#,### plays')",
              },
            },
            clusterMinSize: 20,
          };
        }
      });
    &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;div id="infoDiv" class="esri-widget"&amp;gt;
      Filter by religion:
      &amp;lt;select id="filter" class="esri-select"&amp;gt;
        &amp;lt;option value=""&amp;gt;All&amp;lt;/option&amp;gt;
        &amp;lt;option value="Hindu"&amp;gt;Hindu&amp;lt;/option&amp;gt;
        &amp;lt;option value="Christian"&amp;gt;Christian&amp;lt;/option&amp;gt;
        &amp;lt;option value="Muslim"&amp;gt;Muslim&amp;lt;/option&amp;gt;
        &amp;lt;option value="Buddhist"&amp;gt;Buddhist&amp;lt;/option&amp;gt;
        &amp;lt;option value="Sikh"&amp;gt;Sikh&amp;lt;/option&amp;gt;
        &amp;lt;option value="Jain"&amp;gt;Jain&amp;lt;/option&amp;gt;
      &amp;lt;/select&amp;gt;
      &amp;lt;div style="padding-top: 10px"&amp;gt;
        &amp;lt;button id="toggle-cluster" class="esri-button"&amp;gt;
          Disable Clustering
        &amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;div id="legendDiv"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 15:27:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-underlying-object-id-graphics-in-cluster/m-p/1006969#M71002</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-12-04T15:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Get underlying object id graphics in cluster + programmatically display feature reduction pop up template with custom content</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-underlying-object-id-graphics-in-cluster/m-p/1011165#M71145</link>
      <description>&lt;P&gt;We just added support for querying features within a cluster at version 4.18 - check out this sample to see how it's done and for more information:&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/featurereduction-cluster-query/index.html" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/sample-code/featurereduction-cluster-query/index.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 21:47:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-underlying-object-id-graphics-in-cluster/m-p/1011165#M71145</guid>
      <dc:creator>AnneFitz</dc:creator>
      <dc:date>2020-12-18T21:47:35Z</dc:date>
    </item>
  </channel>
</rss>

