Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to change the active layer in ArcIMS from the default top position to index 2 in the TOC. The TOC has 3 grouped layers, but it is the first grouped layer that I want the active layer to be updated to position 2 not the default position 0. I found this code link from esri showing how to update the active layer, however I can not seem to figure it out. Here is the code from the aimsLayers.js file.

//ActiveLayerIndex=<number of the preferred active layer>;

    if (ActiveLayerIndex>=layerCount) ActiveLayerIndex = 0;
    if (!LayerIsFeature[ActiveLayerIndex]) {
        var chk = 0;

        for (var i=layerCount-1;i>=0;i--) {
            if (LayerIsFeature[i]) chk = i;
        ActiveLayerIndex = chk;

I added the "ActiveLayerIndex=" and changed it to "ActiveLayerIndex=1;" the active layer moved one down to position 1 in the TOC. When I change it to 2 it did not move to position 2 in the TOC and displays no active layer. When I change the index in this line, if (ActiveLayerIndex>=layerCount) ActiveLayerIndex = 0;, it does not update the active layer either. How can I get the active layer to be on the third layer (position 2) in the TOC?


I found another code snippet and was wondering by using it to point to the specific layer name in the TOC if it will re-assign the active layer? Looks like it could be called within the TOC.htm

//global reference to mapframe
    var t = parent.MapFrame;

    function layerName(theFormRef) {
        var theLayerNumber = -1;
        var theLayer = theFormRef.value;

        for (var i=0;i<t.LayerID.length;i++) {
            if (t.LayerName[i] == theLayer){
                theLayerNumber = i
        if (theFormRef.checked) {
            t.LayerVisible[theLayerNumber] = 1;
            //activating layer, NB! raster layers needs to be excluded
        } else {
            t.LayerVisible[theLayerNumber] = 0;

share|improve this question
up vote 0 down vote accepted

After some further investigation I was able to update the active layer through the arcimsparam.js file.

Apparently, layer 3 in the TOC is index 18.

share|improve this answer

From the link you provided:

The ActiveLayerIndex starts with '0' for the topmost layer and its value increases in top to bottom order. So for the third layer to be active, insert the number 2.

So try:

if (ActiveLayerIndex>=layerCount) ActiveLayerIndex = 2;

Their knowledge base says that's how it's done... call ESRI support and submit a ticket.

share|improve this answer
I tried that and it did not work. – artwork21 Jun 29 '11 at 15:25
@artwork, do you have an ESRI support account? If so, submit a ticket. – CaptDragon Jun 29 '11 at 15:44
good idea, thx. – artwork21 Jun 29 '11 at 15:59
can you post the web link of the knowledge base statment? – artwork21 Jun 29 '11 at 16:07
@artwork, it's the same one you posted here. – CaptDragon Jun 29 '11 at 16:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.