Hi all, I try to set visibility for a subLayer set of an ArcGISDynamicMapServiceLayer, but I'm not see setVisibleLayers method. I have tried with constructor as : ArcGISDynamicMapServiceLayer mylayer = new ArcGISDynamicMapServiceLayer(myurl, new int[]{1,2,3} ) but it not work . Please help me if you know . Thank all
On the ArcGISDynamicMapServiceLayer, I think you can call getLayers(), which returns a collection of ArcGISLayerInfos for the sub-layers in that service. ArcGISLayerInfo has setVisible(bool) that you can call. Is this what you're asking for?
Thank Eric for your answer, I have tried with that solution but still not work , all sub-layer still display :
layer.setVisible(true);
ArcGISLayerInfo[] lis = layer.getAllLayers();
for(ArcGISLayerInfo info : lis){
if(info.getId() == 10){
info.setVisible(true);
}else{
info.setVisible(false);
}
}
After this command info.setVisible(true); you have to refresh the MapView object. The only way I found to make it work was mapView.ZoomIn; followed by mapView.ZoomOut;
the same method for info.setVisible(false);