I am in the preliminary stages of developing a widget which will require me to reference a featurelayer. Testing how to loop through layers in the map and then pick out the one I want. I found and inserted the following code which, although it runs fine, does not list the featurelayer.
onOpen<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">function</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
console<SPAN class="punctuation token">.</SPAN><SPAN class="token function">log</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'onOpen'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">for</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">var</SPAN> j <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">;</SPAN> j <SPAN class="operator token"><</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>map<SPAN class="punctuation token">.</SPAN>layerIds<SPAN class="punctuation token">.</SPAN>length<SPAN class="punctuation token">;</SPAN> j<SPAN class="operator token">++</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">var</SPAN> layer <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getLayer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>map<SPAN class="punctuation token">.</SPAN>layerIds<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
console<SPAN class="punctuation token">.</SPAN><SPAN class="token function">log</SPAN><SPAN class="punctuation token">(</SPAN>layer<SPAN class="punctuation token">.</SPAN>id <SPAN class="operator token">+</SPAN> <SPAN class="string token">' '</SPAN> <SPAN class="operator token">+</SPAN> layer<SPAN class="punctuation token">.</SPAN>opacity <SPAN class="operator token">+</SPAN> <SPAN class="string token">' '</SPAN> <SPAN class="operator token">+</SPAN> layer<SPAN class="punctuation token">.</SPAN>visible<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<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>The code generates the following output:
postCreate
WidgetManager.js?wab_dv=2.10:114 widget [widgets/SelectAccidentDemo/Widget] created.
Widget.js?wab_dv=2.10:25 startup
Widget.js?wab_dv=2.10:42 onOpen
Widget.js?wab_dv=2.10:45 World_Street_Map_8421 1 true
Widget.js?wab_dv=2.10:45 AerialPhotos2017_8247 1 true
Widget.js?wab_dv=2.10:45 AGSPro_TileLayer_4565 1 true
Widget.js?wab_dv=2.10:67 onSignOut
All is great except it is missing the hosted featurelayer.
The map is linked here
The featurelayer shows up in the JSON when I log in to ArcGIS Online Assistant.
Thank you ahead of time for any help.