3

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?

0

2 Answers 2

2

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.

3
  • 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
    Commented Dec 11, 2014 at 23:50
  • Can you clarify "doesn't work"? What happens with your second example, with the Testing 123? Commented Dec 12, 2014 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
    Commented Dec 12, 2014 at 18:41
0

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;
}
2
  • 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
    Commented Dec 18, 2014 at 19:45
  • I'm not sure. Why do you need the fieldInfos? Commented Dec 19, 2014 at 20:04

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.