How to flip visibility of Layers in a TiledService

3308
5
02-10-2012 07:21 AM
caseycupp
New Contributor III
I have a Map Layer Control that allows user to control the visibility of various layers.

For Tiled Layers i can't control the sublayer visibility...

ie. for this mapservcie... http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer

I want a user to be able to turn off Layer 1 & 2, but not 0 and 3 .. ( I know you can argue that doesn't make a ton of sense... but it's a sample)

casey
0 Kudos
5 Replies
JenniferNery
Esri Regular Contributor
SetLayerVisibility does not turn off ArcGISTiledMapServiceLayer.Layers visibility: http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.ArcGISTile....

If you want to do this, you would have to use ArcGISDynamicMapServiceLayer and VisibileLayers: http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.ArcGISDyna...
0 Kudos
wangzhifang
Occasional Contributor
Indeed, you can't control visibility of sublayers of a TiledMapServiceLayer from code in client side.
Because when you add a TiledMapServiceLayer in client app(flex/silverlight/js), you actually retrieve several images in PNG/JPEG format from server on every panning/zooming of the map. The images you got from server have already been blended into a single 'layer' from multiple sublayers on server, such as layers of roads, cities, lakes are blended into a single image.
So if you want to control the visibility of TiledMapServiceLayer(cached map service on server), you must set it before caching the map service.

p.s.: If you using ADF or ArcMap as client of your cached map service, you can caching it into multi-layer map service, which generating multiple images of each sublayer, which client will get all of them, and blend them into one image on client side, so you can turn on/off the visibility of a sublayer. But flex/silverlight/js app does not support multi-layer cache, so does ArcGIS Server 10.1.
0 Kudos
AmitGupta
New Contributor

wang,

I have similar kind of problem with my tiled map service, when i upload to arcmap it doesn't allow me to take sublayer turn on and off, how it can be possible. Is there any setting or tools available with new version of Arcgis 10.2 server and desktop 10.2?.

how could I resolve this issue of making sublayer turn on and off with tiled map service?

Thanks,

Amit

0 Kudos
AsserSwelam1
Occasional Contributor

Hi Amit,

Actually you cant do that for TiledLayer and here is why.

When you create a Cached layer or TiledLayer on ArcServer what happened is that ArcServer create small tiles for the map on all available scales and every where. which means thousands of small tiles. And they already created and saved on the server as they was created on ArcMap before turning them in to TiledLayer.

And all what your app do is requesting this small tiles as it is form ArcServer to show them on a Grid as it come to the end to be the map.

You can change the visibility of the sublayers of a DynamicLayer because the DynamicLayer works in different way, your app sends a request to ArcServer requesting a view for a specific extent which is your current location on the map and with some properties like which layers to be visible or not. Then ArcServer creates a new image view for that location with this properties and send it back to your app.

That is why TiledLayers are faster in rendering and DynamicLayers slower but have more dynamic in using it.

Hope that helps you in knowing how they works and what you can do and what you cant.

To achieve what you want you can use DynamicMapService instead of the Tiled one. or create and add a TiledLayer as base map with out the sublayers and add the sublayers separately to the map and you will be able to control them as you want in hiding or showing them. 

Thanks,

Asser

0 Kudos
AmitGupta
New Contributor

Thanks Asser,

I got your point. thanks once again for your nice explanation.

Amit

0 Kudos