[ka-Map-users] KaLegend tweak III

Marc Pfister mpfister at enplan.com
Thu Jan 12 14:30:50 EST 2006


I rearranged a few things in the moveLayer functions so that everything
would move in the right direction when the legend is drawn in the right
direction (as detailed yesterday).

I've never worked on any open source programming before - is this the
kosher way to do it? Email code around?

Marc




function kaLegend_moveLayerDown(){
	var myLayer= this.oLayer;
	var myDiv = this.myDiv;
	var upperLayer= this.oLayer.domObj.previousSibling;
	var upperDiv = this.myDiv.previousSibling;
	var lowerLayer= this.oLayer.domObj.nextSibling;
	var lowerDiv = this.myDiv.nextSibling;
	
	if(lowerDiv.id!='group___base__'){

		//move layer div in the viewport
		var zUp = upperLayer.style.zIndex;
		var zDown = myLayer.domObj.style.zIndex;
	
myLayer.domObj.parentNode.insertBefore(myLayer.domObj,upperLayer);
		//invert zIndex values
		myLayer.domObj.style.zIndex = zUp;
		upperLayer.style.zIndex = zDown;
		
                // move legend group div
		myDiv.parentNode.insertBefore(lowerDiv,myDiv);
		
		//Invert Array Position in aLayers
		var oMap = this.kaLegend.kaMap.getCurrentMap();
                var aLayers = oMap.aLayers;
		var aPosUp = -1;
		var aPosDown = -1;
		var aObjUp = null;
		var aObjDown = null;
		for (var i=0;i<aLayers.length;i++){
                        if(aLayers[i].domObj){
			if(aLayers[i].domObj.id==lowerLayer.id) {
					aPosUp = i;
					aObjUp = aLayers[i];
				}
	
if(aLayers[i].domObj.id==myLayer.domObj.id){
					aPosDown = i;
					aObjDown = aLayers[i];
				}
			}
		}
		oMap.aLayers[aPosDown] = aObjUp;
		oMap.aLayers[aPosUp] = aObjDown;
	} else {
		alert('This layer can\'t be moved below the base
layer');
	}
}


function kaLegend_moveLayerUp(){
	var myLayer= this.oLayer;
	var myDiv = this.myDiv;
  	var upperLayer= this.oLayer.domObj.previousSibling;
	var upperDiv = this.myDiv.previousSibling;
	var lowerLayer= this.oLayer.domObj.nextSibling;
	var lowerDiv = this.myDiv.nextSibling;
	if( upperDiv.className!='kaLegendTitle'){
                
	        
		
		//move layer div
		var zUp = myLayer.domObj.style.zIndex;
		var zDown = lowerLayer.style.zIndex;
	
myLayer.domObj.parentNode.insertBefore(lowerLayer,myLayer.domObj);
		//invert zIndex values
		myLayer.domObj.style.zIndex = zDown;
		lowerLayer.style.zIndex = zUp;
		
		// move legend group div 
		myDiv.parentNode.insertBefore(myDiv,upperDiv);
		
		//Invert Array Position in aLayers
		var oMap = this.kaLegend.kaMap.getCurrentMap();
        var aLayers = oMap.aLayers;
		var aPosUp = -1;
		var aPosDown = -1;
		var aObjUp = null;
		var aObjDown = null;
		for (var i=0;i<aLayers.length;i++){
			if(aLayers[i].domObj){
				if(aLayers[i].domObj.id==upperLayer.id)
{
					aPosUp = i;
					aObjUp = aLayers[i];
				}
	
if(aLayers[i].domObj.id==myLayer.domObj.id){
					aPosDown = i;
					aObjDown = aLayers[i];
				}
			}
		}
		oMap.aLayers[aPosDown] = aObjUp;
		oMap.aLayers[aPosUp] = aObjDown;
	} else {
		alert('This layer is already the top layer');
	}
}


--
Marc Pfister
ENPLAN 
mpfister at enplan.com
530/221-0440
530/221-6963 Fax



More information about the ka-Map-users mailing list