Insert HTML with Arcade

20042
46
Jump to solution
06-28-2017 10:46 AM
ChelseaRozek
MVP Regular Contributor

I'm trying to insert particular icons into a feature's popup based on the feature's attributes. So if the park allows dogs, I want to show a dog icon. Can Arcade insert <img> elements into the popup? I can't seem to get it to work, it just writes the <img> element out as text.

46 Replies
AaronMurphy4
New Contributor

How did you get your images to appear and disappear once you clicked on the different parks? I was able to upload an image in my popup but it appears on every popup but I only want it to show up on certain ones. For example: when I click on the Bollards line it should only the the bollard image and text.

Do I have to create an expression to have the image only show when needed? 

I'm also very new to arcade and learning on the fly. This feed has been very helpful so far. Thank you.

 

0 Kudos
AndreaMcIntosh1
New Contributor III

Yes you have to use the an expression. The correct answer above is the sample that you can follow.

0 Kudos
ChelseaRozek
MVP Regular Contributor

Hi Aaron,

You'll need a field on your features that you can write the expression against. So for example, a field called Bollards that is populated as either 'Yes' or 'No' for every street feature. Then you can use the expression that Brandon gave above to populate the <img>'s src as the image URL when Bollard = 'Yes'. In your screenshot, it looks like you may have a numeric field for Bollards. You could also make the Arcade expression against that and say: iif($feature.Bollards>0,IMAGEURLHERE,'') The blank string at the end for if the statement is false will generate <img src=''> in your popup, which will generate no image.   You create your Arcade expressions to use in the popup with the Add button highlighted below. Check out my screenshots above to see how to set up the HTML in the popup with the expressions once you create them.

Let me know if you have any more questions!

AaronMurphy4
New Contributor

Thank you very much for the responses. I'll let you know how things work out. 

0 Kudos
HeatherMerring
New Contributor II

How did you create the "popup to add title="Dogs Allowed" etc. to <img> so users can hover over the icon with their mouse and double check the meaning"? I'm unsure where this fits into the process.

0 Kudos
ChelseaRozek
MVP Regular Contributor

Hi Heather!

    You're right, that wasn't in my screenshots. When editing the popup, click on the HTML button, then you can add title="meaningofthepicture" within each <img> as seen below for just the first one. I'm using <img> tags with 3 parts: alt, src, and title. They can go in any order, just make sure their values get both start and end quotes. alt provides alternate text for an image if it cannot be displayed or is read when people are using screen readers. src is the source of the image and title is the hover text that you're looking for.

HeatherMerring
New Contributor II

You're awesome! This thread has taught me so much, thank you!

0 Kudos
by Anonymous User
Not applicable

I am trying to get a hover or mouseover effect that give the title or meaning of a image if the user hovers over it with their mouse.  I tried the suggested title="meaning of picture" which works in the web map but not in the pop-up that is displayed in the final WAB website.  I tested in IE and Chrome.  Any tips on how to make it work in the final pop-up application?

XanderBakker
Esri Esteemed Contributor

Hi Angelia Hagopian , 

Have you tried the attribute "alt"  instead of "title"? That is what is used in the example of rozekc_washtenaw 

0 Kudos
by Anonymous User
Not applicable

I did.  It didn't work.  I have been scouring the internet trying to find a solution.  I am just stumped why it works in the web map but not the WAB application.

0 Kudos