I'm still fairly new to Arcade and Javascript. I'm trying to write an Arcade script for my pop-up, and am trying to follow the info in this help page
Arcade - expression language | Guide | ArcGIS API for JavaScript 3.22
where it says this:
"First, write the Arcade expression in a script tag with a unique ID."
I then copied the script sample to edit, which starts with the <script> tag. But in Arcade I am getting the error message 'unexpected token' and it looks like Arcade doesn't read any tag like this <>. I've tried to copy whole pieces of javascript headers etc but it always shows that error.
Thanks for any help.
Kieran
Solved! Go to Solution.
Kieran,
So Arcade in a popup is mainly for math and logical evaluation of field values. You are looking at examples of Arcade in JS code that has a broader capabilities like adjusting renderers and other complex things.
Kieran,
Where are you putting the Arcade expression? Are you inside your web map pop up dialog in portal or in your JS html code? Can you share your code for evaluation.
Hi Robert
Thanks for the quick reply. I'm doing this directly within AGOL using the Configure Pop-up option. I greyed out the tags so that at least I can show something configured within the popup. This code snippet works as is.
//<script type="text/plain" id="education">
// store field values in variables with
// meaningful names. Each is the total count
// of votes for the respective party
var highSchool = $feature.ECYED2564H;
var noHiSchool = $feature.ECYED2564N;
var bachAbove = $feature.V000000046;
var educLevel = [highSchool, noHiSchool, bachAbove];
// Match the maximum value with the label
// of the respective field and return it for
// use in a UniqueValueRenderer
return Decode( Max(educLevel),
highSchool, 'High School',
noHiSchool, 'No High School',
bachAbove, 'Bach and Above',
'n/a' );
//</script>
// Assign the expression to the `valueExpression` property and
// set up the unique value infos based on the decode values
// you set up in the expression.
/*
var educArcade = document.getElementById("education").text;
var renderer = new UniqueValueRenderer({
valueExpression: educArcade,
valueExpressionTitle: "Dominant Education Level",
uniqueValueInfos: [{
value: "highSchool",
symbol: createSymbol("#00c3ff"),
label: "High School"
}, {
value: "noHiSchool",
symbol: createSymbol("#ff002e"),
label: "No High School"
}, {
value: "bachAbove",
symbol: createSymbol("#faff00"),
label: "Bach and Above"
}]
});
*/
So you are trying to create a unique value renderer inside a popups arcade expression?...
Kind of, the maximum/dominant value but translating that back to the field name or assigned text name. As I said, I'm still fairly new to Arcade and javascript.
although this is the kind of thing i would aspire to:
Kieran,
So Arcade in a popup is mainly for math and logical evaluation of field values. You are looking at examples of Arcade in JS code that has a broader capabilities like adjusting renderers and other complex things.
Thanks again Robert, obviously I didn't get the distinction that Arcade is also used within JS code. Looks like that's where I need to explore further.