visibleLayers property in AGSDynamicMapServiceLayer seems to work differently in 1.8

2520
8
05-04-2011 12:42 AM
MiriEshel
New Contributor III
Hi,

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.

Thanks a lot in advance,
Miri
0 Kudos
8 Replies
NimeshJarecha
Esri Regular Contributor
The project do not build (some code files are missing). Can you please correct the build errors and re-upload?

Regards,
Nimesh
0 Kudos
MiriEshel
New Contributor III
Hi Nimesh,

I put the project RoutingForEsri.zip under ftp://ftp.plm.co.il/mirie/.

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.

Thanks again and again,
Miri
0 Kudos
NimeshJarecha
Esri Regular Contributor
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. 

http://www3.emap.co.il/ArcGIS/rest/services/Clients/bp/MapServer/export?bbox=32.4568142279396%2C30.6...

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.

Regards,
Nimesh
0 Kudos
MiriEshel
New Contributor III
Hi Nimesh,

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.

Thanks,
Miri
0 Kudos
NimeshJarecha
Esri Regular Contributor
Send it across...

Regards,
Nimesh
0 Kudos
MiriEshel
New Contributor III
Hi Nimesh,

I put GeocodingSample-ver1.0.zip under ftp://ftp.plm.co.il/mirie/ that points to API 1.0 .
You'll see that there is no problem to remove the last layer with the same code.

Thanks,
Miri
0 Kudos
NimeshJarecha
Esri Regular Contributor
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.

Thanks for reporting.

Regards,
Nimesh
0 Kudos
MiriEshel
New Contributor III
Hi Nimesh,

I've already used the workaround. I was just curious why there is a difference between the two versions regarding the visibleLayers. I'm sure you'll find it and fix it next version!

Thanks so much for all your attention and help!

Miri
0 Kudos