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?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Dec 10, 2014 at 21:53
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.

answered Dec 11, 2014 at 3:02
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 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? 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;
}
answered Dec 18, 2014 at 17:21
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? 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

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.