Map service HasLayerCache method

Determines if a given layer in a map (data frame) has a layer cache.

HasLayerCache(string MapName, int LayerID)

Parameter

Description

MapName

The name of the map (data frame) that contains a layer cache.

LayerID

The layer id of the layer on which a cache is available.

Return Value

A boolean indicating if the layer has a cache (true) or not (false).

Remarks

If the HasLayerCache method returns true, GetCacheName, GetLayerTile, and GetVirtualCacheDirectory methods can be used to return information and image tiles from a layer cache.

Examples

C#

MapService_MapServer mapservice = new MapService_MapServer();

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

string mapname = mapservice.GetDefaultMapName();

MapServerInfo mapinfo = mapservice.GetServerInfo(mapname);

MapDescription mapdesc = mapinfo.DefaultMapDescription;

LayerDescription[] layerdescriptions = mapdesc.LayerDescriptions;

int[] layerids = new int[layerdescriptions.Length];

int i = 0;

foreach (LayerDescription layerdesc in layerdescriptions)

{

      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/MapLayerCache/MapServer"

 

Dim mapname As String = mapservice.GetDefaultMapName()

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapname)

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescrifption

 

Dim layerdescriptions() As LayerDescription = mapdesc.LayerDescriptions

Dim layerids(layerdescriptions.Length-1) As Integer

Dim i As Integer = 0

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

Next

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(layerCacheName);

      }

}

11/8/2016