Hi
I'm trying to populate a popup, but I'm not clear why the popup gets displayed but there is no content. It is not clear if the graphic layer is getting override it and becomes null or undefined. The hosted feature is coming from ArcGIS online, I think there should not be any issue but, you never know. I have attached the files. The steps:
1.Run application locally
2. click on Phoenix feature
3. popup displays without attributes
find repo: https://github.com/mnavidad/UFOSIGHTINGSAPP/tree/master
You mostly had it...perhaps if the documentation for using a function with the content property were more clear on what gets passed to the function, you'd have gotten better results. The following shows the changes you can make to your popupTemplate definition to get it working though:
const popupTemplate = {
title: "You clicked here",
outFields: ["STATE","CITY","DESCRIPTION","DATE_TIME"],
content: function(feature) {
const state = feature.graphic.attributes.STATE;
const city = feature.graphic.attributes.CITY || ""; // Handle missing CITY attribute
const description = feature.graphic.attributes.DESCRIPTION;
const dateTime = feature.graphic.attributes.DATE_TIME;
return `
<div>
<h3>State: ${state}</h3>
${city ? `<h3>City: ${city}</h3>` : ''}
<h3>Description: ${description}</h3>
<h3>Date: ${dateTime}</h3>
</div>
`;
}
};
Thank you so much for replying let me try that 😊