Map service GetCacheName method

Gets the cache name for a given layer within a map (data frame).

GetCacheName(string MapName, int LayerID)

Parameter

Description

MapName

The name of the map (data frame) on which a cache was created.

LayerID

The layer id of the layer in the map on which a cache was created. A multilayer cache can have one cache name for each layer. To get the name of a fused cache, specify a value of -1.

Return Value

A string containing the cache name for the layer specified. If working with a fused cache, the layer id is -1 and the cache name "_alllayers" will be returned.

Remarks

To determine if you are working with a multilayer or fused cache, use the methods HasLayerCache or HasSingleFusedMapCache on the map service proxy. Note that a map service with a multilayer cache may have a cache generated on some layers and not others.

Examples

C#

MapService_MapServer mapservice = new MapService_MapServer();

mapservice.Url = "http://localhost:6080/arcgis/services/MapService/MapServer";

 

string mapname = mapservice.GetDefaultMapName();

 

MapServerInfo mapinfo = mapservice.GetServerInfo(mapname);

MapDescription mapdesc = mapinfo.DefaultMapDescription;

 

LayerDescription[] layerdescriptions = mapdesc.LayerDescriptions;

 

foreach (LayerDescription layerdesc in layerdescriptions)

{

      style="font-size: 12pt;">if (mapservice.HasLayerCache(mapname, layerdesc.LayerID))

      {

            string layercachename = mapservice.GetCacheName(mapname, layerdesc.LayerID);

      }

}

VB.NET

Dim mapservice As MapService_MapServer = New MapService_MapServer()

mapservice.Url = "http://localhost:6080/arcgis/services/MapService/MapServer"

 

Dim mapname As String = mapservice.GetDefaultMapName()

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapname)

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescription

 

Dim layerdescriptions() As LayerDescription = mapdesc.LayerDescriptions

Dim layerdesc As LayerDescription

 

For Each layerdesc In layerdescriptions

 

      If mapservice.HasLayerCache(mapname, layerdesc.LayerID) Then

            Dim layercachename As String = mapservice.GetCacheName(mapname, layerdesc.LayerID)

      End If

Java

String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";

MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);

  

String mapName = mapService.getDefaultMapName();

MapServerInfo mapInfo = mapService.getServerInfo(mapName);

MapDescription mapDesc = mapInfo.getDefaultMapDescription();

  

LayerDescription[] layerDescriptions = mapDesc.getLayerDescriptions();

  

for (LayerDescription layerDesc: layerDescriptions)

{

      if (mapService.hasLayerCache(mapName, layerDesc.getLayerID()))

      {

            String layerCacheName = mapService.getCacheName(mapName, layerDesc.getLayerID());

            System.out.println("Layer Cache Name: " + layerCacheName);

      }

}

2/28/2020