I have a function that pulls the attributes from a feature layer and uses them in a popupTemplate. It works fine when returning the attributes for the top graphic in a layer, but does not return any of the attributes for any overlapped graphics in the same layer. It returns the OBJECTID, but nothing else unfortunately. Thanks in advance for any help.
<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> gr <SPAN class="operator token">=</SPAN> graphic<SPAN class="punctuation token">.</SPAN>graphic<SPAN class="punctuation token">.</SPAN>attributes<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> sku <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>gr<SPAN class="punctuation token">.</SPAN>map_number<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">?</SPAN> gr<SPAN class="punctuation token">.</SPAN>map_number <SPAN class="punctuation token">:</SPAN> <SPAN class="string token">''</SPAN><SPAN class="punctuation token">;</SPAN>
map <SPAN class="operator token">=</SPAN> <SPAN class="string token">"'"</SPAN><SPAN class="operator token">+</SPAN>sku<SPAN class="operator token">+</SPAN><SPAN class="string token">"'"</SPAN><SPAN class="punctuation token">;</SPAN>
console<SPAN class="punctuation token">.</SPAN><SPAN class="token function">log</SPAN><SPAN class="punctuation token">(</SPAN>graphic<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> options <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN>
query<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">{</SPAN>
mapid<SPAN class="punctuation token">:</SPAN> map
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN>
responseType<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"json"</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//console.log(options.query.mapid);</SPAN>
<SPAN class="keyword token">var</SPAN> content <SPAN class="operator token">=</SPAN> <SPAN class="token function">esriRequest</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"../intgeomap/mysqlMapData.php"</SPAN><SPAN class="punctuation token">,</SPAN> options<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">then</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">function</SPAN> <SPAN class="punctuation token">(</SPAN>response2<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">var</SPAN> g <SPAN class="operator token">=</SPAN> response2<SPAN class="punctuation token">.</SPAN>data<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> thmb <SPAN class="operator token">=</SPAN> g<SPAN class="punctuation token">.</SPAN>pub_thumb<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="operator token">!</SPAN> thmb<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="comment token">//check if thumb_graphic field is empty</SPAN>
<SPAN class="keyword token">var</SPAN> image_url <SPAN class="operator token">=</SPAN> <SPAN class="string token">'not-available.png'</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">else</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">var</SPAN> image_url <SPAN class="operator token">=</SPAN> <SPAN class="string token">'https://ugspub.nr.utah.gov/publications/mapthumbs/'</SPAN><SPAN class="operator token">+</SPAN>thmb<SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">var</SPAN> pubtitle <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>g<SPAN class="punctuation token">.</SPAN>pub_name<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">?</SPAN> g<SPAN class="punctuation token">.</SPAN>pub_name <SPAN class="punctuation token">:</SPAN> <SPAN class="string token">' '</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>g<SPAN class="punctuation token">.</SPAN>pub_author <SPAN class="operator token">&&</SPAN> g<SPAN class="punctuation token">.</SPAN>pub_sec_author<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
authors <SPAN class="operator token">=</SPAN> <SPAN class="string token">'<div style="margin-bottom:.5em;"><b>Authors:</b> '</SPAN><SPAN class="operator token">+</SPAN>g<SPAN class="punctuation token">.</SPAN>pub_author<SPAN class="operator token">+</SPAN><SPAN class="string token">', '</SPAN><SPAN class="operator token">+</SPAN>g<SPAN class="punctuation token">.</SPAN>pub_sec_author<SPAN class="operator token">+</SPAN><SPAN class="string token">'<br></div>'</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">else</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>g<SPAN class="punctuation token">.</SPAN>pub_author<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
authors <SPAN class="operator token">=</SPAN> <SPAN class="string token">'<div style="margin-bottom:.5em;"><b>Author:</b> '</SPAN><SPAN class="operator token">+</SPAN>g<SPAN class="punctuation token">.</SPAN>pub_author<SPAN class="operator token">+</SPAN><SPAN class="string token">'<br></div>'</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">else</SPAN> <SPAN class="punctuation token">{</SPAN>
authors <SPAN class="operator token">=</SPAN> <SPAN class="string token">''</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>g<SPAN class="punctuation token">.</SPAN>pub_publisher <SPAN class="operator token">&&</SPAN> g<SPAN class="punctuation token">.</SPAN>series_id <SPAN class="operator token">&&</SPAN> g<SPAN class="punctuation token">.</SPAN>pub_year<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
subTitle <SPAN class="operator token">=</SPAN> <SPAN class="string token">'<div style="margin-bottom:.5em;"><b>Publisher:</b> '</SPAN><SPAN class="operator token">+</SPAN>g<SPAN class="punctuation token">.</SPAN>pub_publisher<SPAN class="operator token">+</SPAN><SPAN class="string token">' | <b>Series ID:</b> '</SPAN><SPAN class="operator token">+</SPAN>g<SPAN class="punctuation token">.</SPAN>series_id<SPAN class="operator token">+</SPAN><SPAN class="string token">' | <b>Date:</b> '</SPAN><SPAN class="operator token">+</SPAN>g<SPAN class="punctuation token">.</SPAN>pub_year<SPAN class="operator token">+</SPAN><SPAN class="string token">'<br></div>'</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">else</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>g<SPAN class="punctuation token">.</SPAN>pub_publisher <SPAN class="operator token">&&</SPAN> g<SPAN class="punctuation token">.</SPAN>series_id<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
subTitle <SPAN class="operator token">=</SPAN> <SPAN class="string token">'<div style="margin-bottom:.5em;"><b>Publisher:</b> '</SPAN><SPAN class="operator token">+</SPAN>g<SPAN class="punctuation token">.</SPAN>pub_publisher<SPAN class="operator token">+</SPAN><SPAN class="string token">' | <b>Series ID:</b> '</SPAN><SPAN class="operator token">+</SPAN>g<SPAN class="punctuation token">.</SPAN>series_id<SPAN class="operator token">+</SPAN><SPAN class="string token">'<br></div>'</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">else</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>g<SPAN class="punctuation token">.</SPAN>pub_publisher <SPAN class="operator token">&&</SPAN> g<SPAN class="punctuation token">.</SPAN>pub_year<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
subTitle <SPAN class="operator token">=</SPAN> <SPAN class="string token">'<div style="margin-bottom:.5em;"><b>Publisher:</b> '</SPAN><SPAN class="operator token">+</SPAN>g<SPAN class="punctuation token">.</SPAN>pub_publisher<SPAN class="operator token">+</SPAN><SPAN class="string token">' | <b>Date:</b> '</SPAN><SPAN class="operator token">+</SPAN>g<SPAN class="punctuation token">.</SPAN>pub_year<SPAN class="operator token">+</SPAN><SPAN class="string token">'<br></div>'</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">else</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>g<SPAN class="punctuation token">.</SPAN>series_id <SPAN class="operator token">&&</SPAN> g<SPAN class="punctuation token">.</SPAN>pub_year<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
subTitle <SPAN class="operator token">=</SPAN> <SPAN class="string token">'<div style="margin-bottom:.5em;"><b>Series ID:</b> '</SPAN><SPAN class="operator token">+</SPAN>g<SPAN class="punctuation token">.</SPAN>series_id<SPAN class="operator token">+</SPAN><SPAN class="string token">' | <b>Date:</b> '</SPAN><SPAN class="operator token">+</SPAN>g<SPAN class="punctuation token">.</SPAN>pub_year<SPAN class="operator token">+</SPAN><SPAN class="string token">'<br></div>'</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">else</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>g<SPAN class="punctuation token">.</SPAN>series_id<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
subTitle <SPAN class="operator token">=</SPAN> <SPAN class="string token">'<div style="margin-bottom:.5em;"><b>Series ID:</b> '</SPAN><SPAN class="operator token">+</SPAN>g<SPAN class="punctuation token">.</SPAN>series_id<SPAN class="operator token">+</SPAN><SPAN class="string token">'<br></div>'</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">else</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>g<SPAN class="punctuation token">.</SPAN>pub_year<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
subTitle <SPAN class="operator token">=</SPAN> <SPAN class="string token">'<div style="margin-bottom:.5em;"><b>Date:</b> '</SPAN><SPAN class="operator token">+</SPAN>g<SPAN class="punctuation token">.</SPAN>pub_year<SPAN class="operator token">+</SPAN><SPAN class="string token">'<br></div>'</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">else</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>g<SPAN class="punctuation token">.</SPAN>pub_publisher<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
subTitle <SPAN class="operator token">=</SPAN> <SPAN class="string token">'<div style="margin-bottom:.5em;"><b>Publisher:</b> '</SPAN><SPAN class="operator token">+</SPAN>g<SPAN class="punctuation token">.</SPAN>pub_publisher<SPAN class="operator token">+</SPAN><SPAN class="string token">'<br></div>'</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">else</SPAN> <SPAN class="punctuation token">{</SPAN>
subTitle <SPAN class="operator token">=</SPAN> <SPAN class="string token">''</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="comment token">//var publisher = (g.pub_publisher) ? '<tr><td colspan="2">'+g.pub_publisher+ '<br><br></td></tr>' : ' ';</SPAN>
<SPAN class="keyword token">var</SPAN> purchase <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>g<SPAN class="punctuation token">.</SPAN>bsurl<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">?</SPAN> <SPAN class="string token">'<div style="margin-bottom:.5em;"><a href="https://www.utahmapstore.com/products/'</SPAN><SPAN class="operator token">+</SPAN>g<SPAN class="punctuation token">.</SPAN>series_id<SPAN class="operator token">+</SPAN><SPAN class="string token">' " target="_blank">Purchase Map <img src="https://geology.utah.gov/apps/geoindex/buy3.png" alt="click to purchase" width="16" height="16" border="0" align="absbottom"></a></div>'</SPAN> <SPAN class="punctuation token">:</SPAN> <SPAN class="string token">' '</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> pdf <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>g<SPAN class="punctuation token">.</SPAN>pub_url<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">?</SPAN> <SPAN class="string token">'<div style="margin-bottom:.5em;"><a href="'</SPAN><SPAN class="operator token">+</SPAN>g<SPAN class="punctuation token">.</SPAN>pub_url<SPAN class="operator token">+</SPAN><SPAN class="string token">'" target="_blank">Open PDF <img src="https://geology.utah.gov/images/pdf16x16.gif" alt="pdf" width="16" border="0" align="absbottom"></a></div>'</SPAN> <SPAN class="punctuation token">:</SPAN> <SPAN class="string token">' '</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> gis <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>g<SPAN class="punctuation token">.</SPAN>gis_data<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">?</SPAN> <SPAN class="string token">'<div style="margin-bottom:.5em;"><a href="https://ugspub.nr.utah.gov/publications/'</SPAN><SPAN class="operator token">+</SPAN>g<SPAN class="punctuation token">.</SPAN>gis_data<SPAN class="operator token">+</SPAN><SPAN class="string token">'" target="_blank">Download GIS Data <img src="https://geology.utah.gov/images/zip16x16.gif" alt="GIS zip file" width="16" height="16" border="0" align="absbottom"></a></div>'</SPAN> <SPAN class="punctuation token">:</SPAN> <SPAN class="string token">' '</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> usgs <SPAN class="operator token">=</SPAN> <SPAN class="operator token">!</SPAN><SPAN class="punctuation token">(</SPAN>g<SPAN class="punctuation token">.</SPAN>pub_url<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">?</SPAN> <SPAN class="string token">'<div style="margin-bottom:.5em;"><a href="https://ngmdb.usgs.gov/ngm-bin/ngm_compsearch.pl" target="_blank">Search USGS for pdf <img src="https://geology.utah.gov/images/pdf16x16.gif" alt="pdf" width="16" border="0" align="absbottom"></a></div>'</SPAN> <SPAN class="punctuation token">:</SPAN> <SPAN class="string token">' '</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> popupText <SPAN class="operator token">=</SPAN> <SPAN class="string token">'<div style="height:100%; line-height:1.3em;">'</SPAN><SPAN class="operator token">+</SPAN><SPAN class="string token">'<div><img style="text-align:center;display:block;margin-left:auto;margin-right:auto;" src="'</SPAN><SPAN class="operator token">+</SPAN>image_url<SPAN class="operator token">+</SPAN><SPAN class="string token">'" border="0" width="225" ></a></div><hr>'</SPAN><SPAN class="operator token">+</SPAN><SPAN class="string token">'<div style="margin-bottom:.5em;">'</SPAN><SPAN class="operator token">+</SPAN><SPAN class="string token">'<b>'</SPAN><SPAN class="operator token">+</SPAN>pubtitle<SPAN class="operator token">+</SPAN><SPAN class="string token">'</b>'</SPAN><SPAN class="operator token">+</SPAN><SPAN class="string token">'<br></div>'</SPAN><SPAN class="operator token">+</SPAN>authors<SPAN class="operator token">+</SPAN>subTitle<SPAN class="operator token">+</SPAN><SPAN class="string token">'<hr>'</SPAN><SPAN class="operator token">+</SPAN>purchase<SPAN class="operator token">+</SPAN>pdf<SPAN class="operator token">+</SPAN>gis<SPAN class="operator token">+</SPAN>usgs<SPAN class="operator token">+</SPAN><SPAN class="string token">'</div>'</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">return</SPAN> popupText<SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">return</SPAN> content<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></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>