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