How to control ArcGIS Server layer visibility in cesium

1. A concise explanation of the problem you're experiencing.

I load a arcgis mapserver in cesium by ArcGisMapServerImageryProvider.There are saying 5 layers in this Arcgis Server map service and I want to control the visibility of each layer individualy.So I make 5 checkboxs in my HTML to control each layer visibility. But I can`t find a method to control layer visibility dynamicly in the class ArcGisMapServerImageryProvider.

How to accomplish it?

Hi there,

You should still be able to toggle the layer visibility with “show” on the imageryLayer itself, see this example (one option is an ArcGisMapServerImageryProvider).

Thanks,

Gabby

Thank you. But what i want to say is that ArcGisMapServerImageryProvider constructor needs a object which contains a property 'layer'. If I assign the layer attribute to '[0,1,2,4]', then I will get the correspoding layers in this arcgis server map service. Now I want to control the '0,1,2,4' layer individualy rather than controlling the visibility of this whole map service.

After I create a ArcGisMapServerImageryProvider instance, I can only read layers property and cannot assign it to a new array to change the layer visibility(not the mapserver visibility).

Oh, I see!

The ArcGisImageryProvider doesn’t make separate ImageryLayers for each ArcGIS layer, but rather requests which layers you specify via the url parameters, the result of which becomes the ImageryLayer shown. You’re correct that you can’t modify the layers property after creation, so I’ve opened #6563 to track adding this feature.

As a workaround, you can destroy the old ArcGisImageryProvider and create a new one with the requested layers when they change.

Thanks,

Gabby