How to work with the ArcIMS API


Summary
This topic shows how to access the ArcIMS application programming interface (API) via an existing Map control, and iterate through the layers in an ArcIMS image or ArcMap service.

Working with the ArcIMS API

The ArcIMS API MapView object is used to access fine-grained ArcIMS service capabilities. The MapView is available via an ArcIMS MapFunctionality. A Map creates a MapFunctionality for each MapResource. By default, the MapFunctionality stores the state of a resource for a Map. However, if the MaintainsState property on a MapFunctionality is false, state is maintained at the resource level. For example, if two Map controls share the same MapResourceManager and do not maintain their state in a MapFunctionality, they will also share the same MapView. Thus, changes to the MapView (that is, changing visible layers) will be reflected in both maps. Changes to a MapView will be maintained for the duration of a session. Examples of this include adding an acetate layer or changing a layer renderer.
See the following code example:
[C#]
foreach (ESRI.ArcGIS.ADF.Web.DataSources.IGISFunctionality gisFunctionality in
    Map1.GetFunctionalities())
{
    if (gisFunctionality is ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality)
    {
        ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality imsMapFunctionality = 
            (ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality)gisFunctionality;

        ESRI.ArcGIS.ADF.IMS.Carto.MapView mapView = imsMapFunctionality.MapView;

        ESRI.ArcGIS.ADF.IMS.Carto.Layer.LayerCollection layerCollection =
            mapView.Layers;

        for (int index = 0; index < layerCollection.Count; index++)
        {
            ESRI.ArcGIS.ADF.IMS.Carto.Layer.Layer layer = layerCollection[index];
            string layerName = layer.Name;
        }

        ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapResource imsMapResource =
            imsMapFunctionality.MapResource;

        ESRI.ArcGIS.ADF.IMS.Carto.MapService mapService = imsMapResource.MapService;
        string mapServiceName = mapService.Connection.ServiceName;
    }
}
[VB.NET]
For Each gisFunctionality As ESRI.ArcGIS.ADF.Web.DataSources.IGISFunctionality In Map1.GetFunctionalities()
    If TypeOf gisFunctionality Is ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality Then
        Dim imsMapFunctionality As ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality = CType(gisFunctionality, ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality)
        
        Dim mapView As ESRI.ArcGIS.ADF.IMS.Carto.MapView = imsMapFunctionality.MapView
        
        Dim layerCollection As ESRI.ArcGIS.ADF.IMS.Carto.Layer.LayerCollection = mapView.Layers
        
        Dim index As Integer = 0
        Do While index < layerCollection.Count
            Dim layer As ESRI.ArcGIS.ADF.IMS.Carto.Layer.Layer = layerCollection(index)
            Dim layerName As String = layer.Name
            index + = 1
        Loop
        
        Dim imsMapResource As ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapResource = imsMapFunctionality.MapResource
        
        Dim mapService As ESRI.ArcGIS.ADF.IMS.Carto.MapService = imsMapResource.MapService
        Dim mapServiceName As String = mapService.Connection.ServiceName
    End If
Next gisFunctionality






Additional Requirements
  • This topic assumes that a MapResourceManager and Map (named Map1) are available in the current scope (for example, in the Page).