up vote0down votefavorite
Basically I have three dynamic map services and I have added all of them onto the map. Everytime I made a selection, I want the layers in my layerlist widget to change and the options displayed will be altered based on what layers are available in each of my map service.
The layer list widget I am using is this: https://developers.arcgis.com/javascript/3/jsapi/layerlist-amd.html
Currently, I call the following function everytime a different map service is selected:
<SPAN class="kwd" style="color: #101094;">function</SPAN><SPAN class="pln" style="color: #303336;"> refresh</SPAN><SPAN class="pun" style="color: #303336;">(</SPAN><SPAN class="pln" style="color: #303336;">curLayer</SPAN><SPAN class="pun" style="color: #303336;">){</SPAN><SPAN class="pln" style="color: #303336;"> widget</SPAN><SPAN class="pun" style="color: #303336;">.</SPAN><SPAN class="pln" style="color: #303336;">refresh</SPAN><SPAN class="pun" style="color: #303336;">({</SPAN><SPAN class="pln" style="color: #303336;"> map</SPAN><SPAN class="pun" style="color: #303336;">:</SPAN><SPAN class="pln" style="color: #303336;"> map</SPAN><SPAN class="pun" style="color: #303336;">,</SPAN><SPAN class="pln" style="color: #303336;"> layers</SPAN><SPAN class="pun" style="color: #303336;">:</SPAN><SPAN class="pln" style="color: #303336;"> </SPAN><SPAN class="pun" style="color: #303336;">[{</SPAN><SPAN class="pln" style="color: #303336;"> layer</SPAN><SPAN class="pun" style="color: #303336;">:</SPAN><SPAN class="pln" style="color: #303336;"> curLayer </SPAN><SPAN class="pun" style="color: #303336;">}] </SPAN><SPAN class="pun" style="color: #303336;">},</SPAN><SPAN class="pln" style="color: #303336;"> </SPAN><SPAN class="str" style="color: #7d2727;">'layerlist'</SPAN><SPAN class="pun" style="color: #303336;">)</SPAN><SPAN class="pun" style="color: #303336;"> }; </SPAN>
However, nothing has changed. Any suggestions?
I don't think the refresh method takes any arguments. Rather redefine the widget.layers property to your new layers array and then call the refresh method.
function refresh(curLayer){ widget.layers = [ {layer: curLayer } ]; widget.refresh(); }
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.