ArcGIS LayerList change layer on refresh

3820
1
05-28-2016 03:41 PM
HeatherSha
New Contributor

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:

function refresh(curLayer){ 
widget.refresh({ 
     map: map, 
     layers: [{ layer: curLayer
 }]
}, 'layerlist')
};

However, nothing has changed. Any suggestions?

0 Kudos
1 Reply
FC_Basson
MVP Regular Contributor

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();
}
0 Kudos