I'm using an Arcade expression in a popup to display observed bird species counts along with an image for point feature layer. The code runs without errors in the Arcade editor. The image is also loading correctly from the "Image_url" field in pop-up. However, the species count part is not showing up at all. Instead, I only see the fallback message "No Species Data Available"
Here is the Arcade expression:
// Dictionary to map species codes to full names
var speciesMap = {
"EABL": "Eastern Bluebird",
"MOBL": "Mountain Bluebird",
"WEBL": "Western Bluebird",
"PABU": "Painted Bunting",
"AMGO": "American Goldfinch",
"LEGO": "Lesser Goldfinch",
"BHNU": "Brown-headed Nuthatch",
"PYNU": "Pygmy Nuthatch",
"RBNU": "Red-breasted Nuthatch",
"WBNU": "White-breasted Nuthatch",
"EATO": "Eastern Towhee",
"SPTO": "Spotted Towhee"
};
// // Function to place image to the side of the text
function buildbox(imageURL, txt) {
return '<figure class="table"><table><tbody><tr><td width=100px;height=100px><img src="' + imageURL + '" alt="" height=100 width=100 /></td><td width=20px></td><td>' + txt + '</td></tr></tbody></table></figure>';
};
// Initialize an empty list for observed species
var validSpecies = [];
// Iterate through species dictionary
for (var speciesCode in speciesMap) {
// Safely get value or null if field doesn't exist
var speciesCount = When(
IsEmpty($feature[speciesCode]), null,
$feature[speciesCode]
);
if (!IsEmpty(speciesCount)) {
Push(validSpecies, speciesMap[speciesCode] + ": " + speciesCount);
}
}
// Format observed species text
var speciesText = Concatenate(validSpecies, TextFormatting.NewLine);
// Get image URL safely
var imgUrl = "";
if (HasKey($feature, "Image_url")) {
imgUrl = $feature.Image_url;
}
// Debugging output: Check if speciesText is empty
if (IsEmpty(speciesText)) {
speciesText = "<p style='color:pink;'>No species data available.</p>";
}
var finalText = buildbox(imgUrl, "<b>Observed Species Count</b><br>" + speciesText)
return{
type : 'text',
text : finalText
}
This is the output result which I believe it'correct
This is the web map link which one I am trying to configure the pop-up.
I have been able to solve this problem!