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",
},
],
};
Solved! Go to Solution.
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!
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
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!
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!