I am building a extension of the PrintWidget which will print a specific basemap+featureLayer+other settings. For example, it will have a button which when clicked will print the current map, including whatever the user uploaded with the AddData widget, but using the basemap "streets" and a specific FeatureLayer or two.
In this thread I learned how to programmatically change the basemap. Now I want to add layers to this new basemap (before printing). But, I cannot find a way to do it.
I looked at other threads for possible examples, but they did not work. Namely, this code:
var featureLayer = new FeatureLayer(url);
this.map.addLayer(featureLayer);
does not actually show the new layer. The code does add the new layer to the LayerList widget (which I did not want), and it is even checked, but data from the layer does not show up on the map.
What I would like is a way to programmatically "click" (show/hide) on a layer in the LayerList widget, from a different widget. Any ideas?