Select to view content in your preferred language

Popup link in attribute expression go back to my webmap

426
4
12-13-2022 02:08 PM
TimHayes3
Occasional Contributor

Two of the 3 links in my popup work fine and go to the website in the var link, until I click on a point that references 'Type IV'. When I click on any point in my webmap that is Type IV, the link goes to my webmap. 

if ($feature.RESOURCETYPE == "Type II (500 - 1,999 persons)")
{return link = 'Type II';}
if ($feature.RESOURCETYPE == "Type III (250 - 499 persons)")
{return link = 'Type III';}
If ($feature.RESOURCETYPE == "Type IV (249 or fewer persons)")
{return link = 'Type IV';}
 
Any ideas on why this is happening? I queried and double checked that  "Type IV (249 or fewer persons)" is correct in the attribute table.
0 Kudos
4 Replies
jcarlson
MVP Esteemed Contributor

I don't see how that expression returns the URL. Is it link += 'Type'? Reading your expression, those conditions would result in link being overwritten.

Also, when you're just mapping a single attribute to different outputs, you could use Decode instead.

var t = Decode($feature.RESOURCETYPE,
    'Type II (500 - 1,999 persons)', 'Type II',
    'Type III (250 - 499 persons)', 'Type III',
    'Type IV (249 or fewer persons)', 'Type IV',
    '')
    
If (!IsEmpty(t)){
    return `your-url/${t}`
} else {
    return 'no link'
}
- Josh Carlson
Kendall County GIS
TimHayes3
Occasional Contributor

Decode works better, thank you. But, 'no link' shows up in my popup as a link to my webmap. Any thoughts on how to ensure it is text and not a Link?

0 Kudos
jcarlson
MVP Esteemed Contributor

Where exactly is this being used? Is the map public? I can't really tell why it would behave this way without more context.

- Josh Carlson
Kendall County GIS
0 Kudos
TimHayes3
Occasional Contributor

The map is not public. I modified your code a tad bit:

var t = Decode($feature.RESOURCETYPE,
    'Type II (500 - 1,999 persons)', 'Type II (500 - 1,999 persons)',
    'Type III (250 - 499 persons)', 'Type III (250 - 499 persons)',
    'Type IV (249 or fewer persons)', 'Type IV (249 or fewer persons)',
    '')
   
If ($feature.RESOURCETYPE != "TBD - Leave Blank"){
    return link = t
} else {
    return 'no link'
}
 
Here is what it looks like with 'no link' in the popup:
XV1.JPG
 
Here is what the Text box has:
XV2.JPG
0 Kudos