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?
2 Answers 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.
-
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– TriFu2014年12月11日 23:50:30 +00:00Commented Dec 11, 2014 at 23:50 -
Can you clarify "doesn't work"? What happens with your second example, with the Testing 123?Stephen Lead– Stephen Lead2014年12月12日 00:25:07 +00:00Commented 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– TriFu2014年12月12日 18:41:18 +00:00Commented Dec 12, 2014 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– TriFu2014年12月18日 19:45:04 +00:00Commented Dec 18, 2014 at 19:45
-
I'm not sure. Why do you need the fieldInfos?Andrew Pratt– Andrew Pratt2014年12月19日 20:04:23 +00:00Commented Dec 19, 2014 at 20:04
Explore related questions
See similar questions with these tags.