I'm trying to migrate an application from version 1.0 to 1.8 of the API for iOS. In this application, we let the user select which layers he wants to show out of a list of 4 layers of a dynamic layer. Behind the scene it updates the visibleLayers array of this AGSDynamicMapServiceLayer. It worked fine in version 1.0 but it looks like it doesn't work as expected in ver. 1.8. For instance, if I have only one layer that is shown on the map, when I try to turn this layer off, it doesn't do it, although [self.dynamicLayer.visibleLayers count] = 0. The layer is still shown on the map.
In order to reproduce the problem, I put the project's code on ftp.plm.co.il/mirie user: systematics password: System2030
When the application opens, zoom in to a fairly small area (try to aim to the middle of Israel, near the sea). Then you choose the right most tab Bar item in the bottom screen. When it opens, you choose layers to show by clicking on the name. Finally you have to click on the button in the upper right side of the view to execute it. Then try to click again to remove them. If you remove them in one hit, it doesn't remove any of the layers. If you remove each layer separately, it works OK except the last layer. The logic runs in viewDidAppear function in MapViewController.m I hope I made myself clear. Maybe I do something wrong, but exactly the same code worked perfect in 1.0.
When you run it, please click on the right button of the bottom toolbar. You'll see two layers: Sites & Battery exchange. Click on sites, you'll see the layer displayed on the map, then click Battery exchange, you'll see another layer displayed on the map, then click again on one of the layers' name, it will be removed from the map display. Finally try to remove the other layer - it is NOT removed from the map. Why ? If you try to remove both of them together, no one is removed.
In 1.0, the last layer was removed with no problems.
There is no change in the AGSDynamicMapServiceLayer::visibleLayers from v1.0 to v1.8. I doubt it behaved differently. In the scenario, when you check-off both the layers, the request for AGSDynamicMapServiceLayer::visibleLayers goes with an empty array. You can replicate same with following URL.
It throws an error and dynamic layer do not get updated. Hence, you see both the layers.
If you want to display off all the sub layers of a dynamic service then hide the dynamic service instead. When you add a dynamic map service to the map it returns (UIView< AGSLayerView > *). You can use hidden property of it.
We'll see, if we can improve experience in the case of display off all the sub layers of a dynamic service.
It's strange. As I mentioned previously, I took exactly the same code that I wrote for 1.0, where it worked perfectly with the last layer too. I can send the app that points to version 1.0 if you want (if you still have the api installed). Both work against ArcGIS Server 10.
My bad..:( Indeed, it behaves differently. We'll fix this in the next version of API release. Use a workaround until we fix it.
Workaround: If you want to display off all the sub layers of a dynamic service then hide the dynamic service's view instead. When you add a dynamic map service to the map it returns (UIView< AGSLayerView > *). You can use *hidden* property of it.