I initially posted this question in the 10.1 beta forum but thought this might be the better place for it.
I'm having problems toggling the visibility of layers in a dynamically-drawn map service (10.1 beta 2) using the JavaScript API (versions 2.5 and 2.6 behave the same).
Using the Service Editor, under Capabilities > Mapping, I've enabled "Allow per request modification of layer order and symbology," but this did not solve the problem.
The strange thing is that it seems to work partially, because my layer does appear when I first set its visibility (as long as I am at the initial map extent). But when I pan or zoom, the layer becomes broken and does not redraw at any scale, and if I call
layer.setVisibleLayers([-1]);
to turn all layers off, the layer remains on screen.
The DynamicMapServiceLayer displays fine if I specify the visible layer IDs in the ImageParameters property during construction, but as soon as I call setVisibleLayers() it becomes broken.
Very strange behavior. A bug in 10.1 or the JavaScript API I wonder?