0

I have a feature layer in AGOL Map Viewer full of polygons. This feature layer has a field titled 'dotcms_factsheet'. In each cell in this field is a URL. I am trying to write an expression in Popups that returns the URL as the hyperlinked word 'Link' in the popup text when the user clicks on a respective polygon:

enter image description here

I cannot figure out how to do this. The existing word Link in blue is just something I typed to show what I want to do.

I have some code someone graciously shared with me, but it is only good for an Arcade Element:

var output = `<a href="${$feature.dotcms_factsheet}">Link</a>`

return { 
    type : 'text', 
    text : output
}

However, I do not know how to add an Arcade Element into the Text in AGOL Map Viewer Popups. So this isn't working for me.

I also have this code I have included as an Expression:

// Check if dotcms_factsheet field is not empty
var url = $feature.dotcms_factsheet;
if (!IsEmpty(url)) {
    var linkText = "Link";
    var link = "<a href='" + url + "' target='_blank'>" + linkText + "</a>";
    return link;
} else {
    return "No URL available";
}

However, this code returns:

DOTCMS Fact Sheet: a href='http://dotcmsclp.dot.net:9080/navigator/boo...642BB22053%7D' target='_blank'>Link</a>

I believe the problem is with the grammar in this line. I think the ' and " may be wrong:

var hyperlink = "<a href='" + url + "' target='_blank'>" + linkText + "</a>";

1 Answer 1

0

Since you are attempting to put this into a text element, arcade is not the tool you need!

You are able to simply open the html editor for the text element (looks like a piece of paper with a pencil and angle brackets on it), and write normal html. So in your case, it would look something like this -

   <p>
       <b>DOTCMS Factsheet:</b> <a href="{dotcms_factsheet}">Link</a><br>
       <b>Next Category:</b>.....
   </p>

This will result in what you are trying to achieve.

1
  • Also worth noting, you can repeat this to reference in any field value as plain text by just dropping the <a> tag and reference the field name with curly brackets. You don't need to use the arcade $feature.FIELD_NAME to access your fields in the HTML editor. Commented Jul 3 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.