Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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>;
    ActiveLayerIndex=1;

    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?

UPDATE

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
            setActiveLayer(theLayerNumber);
        } else {
            t.LayerVisible[theLayerNumber] = 0;
        }
        t.sendMapXML();
    }

http://forums.esri.com/Thread.asp?c=64&f=786&t=278849

Thanks

share|improve this question

2 Answers 2

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;

Edit #1

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
up vote 0 down vote accepted

Update: Well 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, go figure.

share|improve this answer

Your Answer

 
discard

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.