ArcGIS Javascript adding an extra row to featurereduction popup

385
3
Jump to solution
02-08-2023 01:54 PM
GeospatialEnterprise
New Contributor II
 

 

geoJSONLayer.featureReduction = {
          type: "cluster",
          outFields: ["*"],
          popupTemplate: template,
          clusterRadius: 25,
          clusterMinSize: "50px",
          clusterMaxSize: "50px,
          labelingInfo: [
            {
              deconflictionStrategy: "none",
              labelExpressionInfo: {
                expression: "Text($feature.cluster_count, '#,###')",
              },
              symbol: {
                type: "text",
                color: "white",
                font: {
                  weight: "bold",
                  family: "Noto Sans",
                  size: "14px",
                },
                haloSize: 1,
                haloColor: "black",
                yoffset: "-8pt",
              },
              labelPlacement: "center-center",
            },
          ],
        };

Screenshot 2023-02-08 165057.png

 

0 Kudos
1 Solution

Accepted Solutions
GeospatialEnterprise
New Contributor II

 

view.on("click", async (event) => {
          const layerView = await view.whenLayerView(geoJSONLayer);
          const response = await view.hitTest(event, { include: geoJSONLayer });
          console.log(response);
          const cluster = response.results[0].graphic;
      
          const id = cluster.getObjectId();
          const q = layerView.createQuery();
          q.aggregateIds = [id];
          const { features } = await layerView.queryFeatures(q);
          //console.log(features.results[0]);
          if (features.length === 0) {
            geoJSONLayer.popupTemplate = template;
          } else {
            view.popup.open({ features });
          }
          
        });

 Here's the code to how I solved it!

 

View solution in original post

0 Kudos
3 Replies
ReneRubalcava
Frequent Contributor

Does your PopupTemplate have a title property? If it doesn't, you get this "Untitled" text for the summary row. You can review this sample to help.

https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=featurereduction-cluster

GeospatialEnterprise
New Contributor II

That syntax was very annoying.. It was counting the summary and it makes it appear as if there were an additional feature in the scroll. I ended up bypassing the browse features button with view.popup.open for the cluster features and the popup template for the single points!

0 Kudos
GeospatialEnterprise
New Contributor II

 

view.on("click", async (event) => {
          const layerView = await view.whenLayerView(geoJSONLayer);
          const response = await view.hitTest(event, { include: geoJSONLayer });
          console.log(response);
          const cluster = response.results[0].graphic;
      
          const id = cluster.getObjectId();
          const q = layerView.createQuery();
          q.aggregateIds = [id];
          const { features } = await layerView.queryFeatures(q);
          //console.log(features.results[0]);
          if (features.length === 0) {
            geoJSONLayer.popupTemplate = template;
          } else {
            view.popup.open({ features });
          }
          
        });

 Here's the code to how I solved it!

 

0 Kudos