I was wondering how do I add a video to be played in the popup template?

I've looked at the documentation here: https://developers.arcgis.com/javascript/jssamples/widget_extendInfowindow.html

and can't seem to find any information on it?


The last line of the getTextContent function in that sample shows how an infoWindow can contain HTML:

return "<b>" + commName + "</b><br /><a target='_blank' href=http://en.wikipedia.org/wiki/" + sciName  +">Wikipedia Entry</a>";

You can set this using infoWindow.setContent, and point to the location of the video.

From this point you can use standard HTML video tags, or the embed link from YouTube, Vimeo, etc.

  • Does this work for PopupTemplate as well? I'm actually using PopupTemplate. I find that when I'm trying to set title by doing this it doesn't work: code var popupTemplate = PopupTemplate(); popupTemplate.setTitle("<h2>YOLO</h2>"); popupTemplate.setContent(loadVideo); popupTemplate.setContent("<div><p>Testing 123</p></div>");/code – TriFu Dec 11 '14 at 23:50
  • Can you clarify "doesn't work"? What happens with your second example, with the Testing 123? – Stephen Lead Dec 12 '14 at 0:25
  • My apologies. What I meant is that it only displays the last thing I set to it (i.e. test 123). The setContent(loadVideo) does not call on the function loadVideo, and the setTitle does not set the title. I was hoping to be able to set a bunch of fieldsInfos to it, and then load a video at the bottom? – TriFu Dec 12 '14 at 18:41

Do something like this...

//works Template            
        var template  = new PopupTemplate();    
        template.setTitle("<b>Works Point</b>");        
        template.setContent(getContent); //this will call the getContent function where you can custom build your fields and add video

function getContent(graphic){   
Content = "Project Name:" + graphic.attributes.NAME + "<br> Prov:" + graphic.attributes.PROV;                          

Hyperlink = "Hyperlink: <a href='http://www.youtube.com'>Project Link</a>"

return Content + Hyperlink;
  • Hi Andrew, thanks for your answer! I was wondering how would I be able to still use fieldInfos[] with the setContent() method? This link uses fieldInfos, but I don't see them ever using them together? developers.arcgis.com/javascript/jsapi/popuptemplate.html and when I tried to use them together the fieldInfos never showed? – TriFu Dec 18 '14 at 19:45
  • I'm not sure. Why do you need the fieldInfos? – Andrew Pratt Dec 19 '14 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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