I am trying to embed a URL into my pop-ups for a rubbish collection map.
If the collection week of a boundary is week one, I want the URL to go to the week one page.
If the collection week of a boundary is week two, I want the URL to go to the week two page.
I would like the URL to be embed into the word "here" in the pop-up as seen below:
What expression is needed to pass through the correct URL for each pop-up? I have started with what I have below but am aware URLs need to be formatted in a certain way. Any pointers much appreciated!
if ($feature.Week == "Week 1") {
return "https://www.ashburtondc.govt.nz/?a=57072"
}
if ($feature.Week == "Week 2") {
return "https://www.ashburtondc.govt.nz/?a=57073"
}
Solved! Go to Solution.
I found another way around it, using the expression below:
var calendarone = "https://www.ashburtondc.govt.nz/?a=57072"
var calendartwo = "https://www.ashburtondc.govt.nz/?a=57073"
if ($feature.Week == 'Week 1') {
return calendarone
}
else {
return calendartwo
}
You'll want to add the Arcade as an attribute expression, and then point the hyperlink to that expression. It looks like you're using Map Viewer Classic, so that button is here:
Once you're there, try adding this expression:
var week = $feature.Week
decode(week, "Week 1", "https://www.ashburtondc.govt.nz/?a=57072", "Week 2", "https://www.ashburtondc.govt.nz/?a=57073")
Then, with "here" selected in your popup configuration, click Link and enter the name of your attribute expression in brackets, like this:
Click 'Update.'
Hi @wayfaringrob thanks for your help!
I have created that as a new expression however am getting the error "Execution Error: Must have a default value result."
Am I missing something here? Thanks!
Hi again @wayfaringrob, I added the default value to the end of the expression and tested with no error.
var week = $feature.Week
decode(week, "Week 1", "https://www.ashburtondc.govt.nz/?a=57072", "Week 2", "https://www.ashburtondc.govt.nz/?a=57073", default)
The pop-up has recognised the word "here" as a hyperlink in the pop-up however it does not navigate to anywhere/can't be clicked. Am I missing something here? Thanks!
I found another way around it, using the expression below:
var calendarone = "https://www.ashburtondc.govt.nz/?a=57072"
var calendartwo = "https://www.ashburtondc.govt.nz/?a=57073"
if ($feature.Week == 'Week 1') {
return calendarone
}
else {
return calendartwo
}
Nice! Yeah, the Arcade documentation said the default portion was optional so I'm not sure why it didn't work that way.
Thanks for your help @wayfaringrob 🙂