I am trying to modify the code found at https://community.esri.com/thread/121245 to use a text field from the attribute table of the layer for the URL of the video. I am new to Javascript, so I'm struggling. I need to change line 7 so that the src is text from my attribute table. thx...
Ruth,
You are using an attribute already from data in that method "pop2000" so it is not much different:
<SPAN class="keyword token">var</SPAN> template <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">PopupTemplate</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> template<SPAN class="punctuation token">.</SPAN><SPAN class="token function">setTitle</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"<b>City</b>"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> template<SPAN class="punctuation token">.</SPAN><SPAN class="token function">setContent</SPAN><SPAN class="punctuation token">(</SPAN>getContent<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">//this will call the getContent function where you can custom build your fields and add video </SPAN> <SPAN class="keyword token">function</SPAN> <SPAN class="token function">getContent</SPAN><SPAN class="punctuation token">(</SPAN>graphic<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> Content <SPAN class="operator token">=</SPAN> <SPAN class="string token">"<b>City Name: </b>"</SPAN> <SPAN class="operator token">+</SPAN> graphic<SPAN class="punctuation token">.</SPAN>attributes<SPAN class="punctuation token">.</SPAN>areaname <SPAN class="operator token">+</SPAN> <SPAN class="string token">"<br> <b>Population: </b>"</SPAN> <SPAN class="operator token">+</SPAN> graphic<SPAN class="punctuation token">.</SPAN>attributes<SPAN class="punctuation token">.</SPAN>pop2000 <SPAN class="operator token">+</SPAN> <SPAN class="string token">"<br>"</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> Hyperlink <SPAN class="operator token">=</SPAN> <SPAN class="string token">'<video width="250" height="250" controls><source src='</SPAN> <SPAN class="operator token">+</SPAN> graphic<SPAN class="punctuation token">.</SPAN>attributes<SPAN class="punctuation token">.</SPAN>videourl <SPAN class="operator token">+</SPAN> <SPAN class="string token">' type=video/mp4></video> '</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">return</SPAN> Content <SPAN class="operator token">+</SPAN> Hyperlink<SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Thanks!!!
Don't forget to mark this question as answered by clicking on the "Correct Answer" link on the reply that answered your question.
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.