Hello Everyone,
So, I want to use Conditional Field Display with Arcade in my Pop-Ups. I have done all the reading and research I could find, but I can't seem to figure it out.
Here is the link to my current map, it is public, showing my current pop ups, as a custom attribute expression I created.
You'll notice that in the pop ups, certain amounts are set to 0, this is the value if no value is inputted into the table. There are some locations that won't get certain types of fish, and that's where I would like to have certain things not show in my pop up.
For example:
Solved! Go to Solution.
For each of your fish species, create an Arcade expression:
// show_fish_species_1
// returns 'inline' if the field is not empty, else 'none'
// If your empty fields are filled with 0, use this
return IIF($feature.FishSpecies1 == 0, 'none', 'inline')
// If your empty fields are empty, use this
return IIF(IsEmpty($feature.FishSpecies1), 'none', 'inline')
// Or just do both
return IIF(IsEmpty($feature.FishSpecies1) || $feature.FishSpecies1 == 0, 'none', 'inline')
Edit the HTML source of you popup (your example sentences seem a little too complex to do this way, so I remodeled a bit):
{Location} was stocked
<div style="display:{expression/show_brook_trout_1};">
with {BrookTrout1} spring yearling Brook Trout on {SurveyDate1},
</div>
<div style="display:{expression/show_brook_trout_2};">
with {BrookTrout2} 2 year old Brook Trout on {SurveyDate2},
</div>
<div style="display:{expression/show_raibow_trout_1};">
with {RainbowTrout1} spring yearling Rainbow Trout on {SurveyDate3},
</div>
<div style="display:{expression/show_raibow_trout_2};">
and with {RainbowTrout2} 2 year old Rainbow Trout on {SurveyDate4},
</div>
.
If you always survey all fish of the same species, you can do
{Location} was stocked
<div style="display:{expression/show_brook_trout};">
with {BrookTrout1} spring yearling Brook Trout on {SurveyDate1} and {BrookTrout2} 2 year old Brook Trout on {SurveyDate2}.
</div>
<div style="display:{expression/show_raibow_trout};">
It was also stocked with {RainbowTrout1} spring yearling Rainbow Trout on {SurveyDate3} and with {RainbowTrout2} 2 year old Rainbow Trout on {SurveyDate4}.
</div>
.
The basic idea is simple: put parts of the text in <div> tags and show or hide these (display: inline/none) according to your number fields. Depending on the structure of your surveys and popup sentences, it could get pretty complex.
@AmandaBeck Can you post the arcade script you have so far?
I don't have one yet, I am just starting out. All I have is a custom attribute display of the information I want presented when a pop up is open. My issue is having certain information not show if the data in my table is 0, or not present at all.
Here's my custom attribute display as of now:
{Waterbody} was stocked with {STY} spring yearling Brook Trout on {STY_Date} and {ST2Y} 2 year old Brook Trout on {ST2Y_Date}. It was also stocked with {RTY} spring yearling Rainbow Trout on {RTY_Date} and {RT2Y} 2 year old Rainbow Trout on {RT2Y_Date}. There were also {RTFY} fall stock yearling Rainbow Trout stocked on {RTFY_Date}.
For each of your fish species, create an Arcade expression:
// show_fish_species_1
// returns 'inline' if the field is not empty, else 'none'
// If your empty fields are filled with 0, use this
return IIF($feature.FishSpecies1 == 0, 'none', 'inline')
// If your empty fields are empty, use this
return IIF(IsEmpty($feature.FishSpecies1), 'none', 'inline')
// Or just do both
return IIF(IsEmpty($feature.FishSpecies1) || $feature.FishSpecies1 == 0, 'none', 'inline')
Edit the HTML source of you popup (your example sentences seem a little too complex to do this way, so I remodeled a bit):
{Location} was stocked
<div style="display:{expression/show_brook_trout_1};">
with {BrookTrout1} spring yearling Brook Trout on {SurveyDate1},
</div>
<div style="display:{expression/show_brook_trout_2};">
with {BrookTrout2} 2 year old Brook Trout on {SurveyDate2},
</div>
<div style="display:{expression/show_raibow_trout_1};">
with {RainbowTrout1} spring yearling Rainbow Trout on {SurveyDate3},
</div>
<div style="display:{expression/show_raibow_trout_2};">
and with {RainbowTrout2} 2 year old Rainbow Trout on {SurveyDate4},
</div>
.
If you always survey all fish of the same species, you can do
{Location} was stocked
<div style="display:{expression/show_brook_trout};">
with {BrookTrout1} spring yearling Brook Trout on {SurveyDate1} and {BrookTrout2} 2 year old Brook Trout on {SurveyDate2}.
</div>
<div style="display:{expression/show_raibow_trout};">
It was also stocked with {RainbowTrout1} spring yearling Rainbow Trout on {SurveyDate3} and with {RainbowTrout2} 2 year old Rainbow Trout on {SurveyDate4}.
</div>
.
The basic idea is simple: put parts of the text in <div> tags and show or hide these (display: inline/none) according to your number fields. Depending on the structure of your surveys and popup sentences, it could get pretty complex.
Thank you @JohannesLindner
This gave me an overview of how to use Arcade Expressions and how I wanted to display my data. I think I understand how it works now, I'll just have to do some tweaking but this explanation was greatly appreciated!