⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aimsmap.js

📁 arcmis是webgis网站的掩码
💻 JS
📖 第 1 页 / 共 2 页
字号:
		if (endpos==-1) endpos = cmdString.length;
		limitBottom = cmdString.substring(startpos,endpos);
	}
	pos = cmdString2.indexOf("EXTENT=AUTO");
	if (pos!=-1) {
		startLeft=0;
		startRight=0;
		startTop=0;
		startBottom=0;
		limitLeft=0;
		limitRight=0;
		limitTop=0;
		limitBottom=0;
		getStartingExtent=true;
		getLimitExtent=true;
	}
	pos = cmdString2.indexOf("DEBUG=YES");
	if (pos==-1) pos = cmdString2.indexOf("DEBUG=TRUE");
	if (pos!=-1) {
		debugOn=3;
	}
	
	//alert("imsURL=" + imsURL + "\nimsOVURL=" + imsOVURL);
	if (imsURL!="") {
		imsQueryURL= imsURL + "&CustomService=Query";
		imsGeocodeURL = imsURL + "&CustomService=Geocode";
		//canLoad=false;
	} 
	// if starting extents zero'd then flag to get start from mapservice
	if ((startLeft!=0) && (startRight!=0)) getStartingExtent=false;
	// if limit extents zero'd then flag to get max from mapservice
	if ((limitLeft!=0) && (limitRight!=0)) {
		getLimitExtent=false;
		enforceFullExtent=true;
	}
}

// get directory path of URL
function getPath(theFullPath) {
	var theSlash = theFullPath.lastIndexOf("/");
	var theDir = theFullPath.substring(0,theSlash);
	if (theDir==null) theDir="";
	theDir = theDir + "/";
	return theDir;

}

// check for existance of layer
function hasLayer(name) {
	var result = false;
	if (isNav4) {
		if (document.layers[name]!=null) result=true;
	}  else if (isIE) {
		if (eval('document.all.' + name)!=null) result=true;
	} else if (isNav) {
		var theElements = document.getElementsByTagName("DIV");
		var theObj;
		var j = -1;
		for (i=0;i<theElements.length;i++) {
			if (theElements[i].id==name) result=true;
		}
    }
	return result;
}

// put up the "RetriveData" image
function showRetrieveData() {
	if (hasLayer("LoadData")) {
		showLayer("LoadData");
	}
}

// hide the "RetriveData" image
function hideRetrieveData() {
	if (hasLayer("LoadData")) {
		hideLayer("LoadData");
	}
}

// put up the "RetriveMap" image
function showRetrieveMap() {
	if (hasLayer("LoadMap")) {
		showLayer("LoadMap");
	}
}

// hide the "RetriveMap" image
function hideRetrieveMap() {
	if (hasLayer("LoadMap")) {
		hideLayer("LoadMap");
	}
}

/*  *****************************************************
*	Various Distance Conversion Functions
*	*****************************************************
*/

// get scale bar distance
function getScaleBarDistance() {
	// get distance from left and right values in map units
	// convert to ScaleBar units then clip to ScaleBar size
	
	// Note: decimal are not hard coded to allow use with locales using commas instead of points.
	var mUnits = MapUnits;
	var mDistance = eRight - eLeft;
	var sbDistance = 0
	if (MapUnits=="DEGREES") {
		// if DEGREES then convert to feet
			// first get mid y point
		var midY = eBottom + (eTop-eBottom)/2;
		var tempL = eLeft;
		var tempR = eRight;
		if (tempL<-180) tempL = (-1799999 /10000);
		if (tempR>180) tempL = (1799999/10000);
		var Lon1 = tempL * Math.PI / 180;
		var Lon2 = tempR * Math.PI / 180;
		var Lat1 = midY * Math.PI / 180;
		var Lat2 = midY * Math.PI / 180;
		var LonDist = Math.abs(Lon2-Lon1);
		var LatDist = Math.abs(Lat1-Lat2);
		var A = Math.pow(Math.sin(LatDist / 2),2) + Math.cos(Lat1) * Math.cos(Lat2) * Math.pow(Math.sin(LonDist /2),2);
		//var A = Math.cos(Lat1) * Math.cos(Lat2) * Math.pow(Math.sin(LonDist /2),2);
		var C = 2 * Math.asin(Math.min(1, Math.sqrt(A)));
		var D = (3963 - 13 * Math.sin((Lat1 + Lat2) / 2)) * C
		
		mDistance = D * 5280;
		mUnits = "FEET";
	}
	if (mUnits != ScaleBarUnits) {
		theDist = mDistance
		mDistance = convertUnits(theDist,mUnits,ScaleBarUnits);
	}
	
	sbDistance = mDistance/5;
	// /*
	var num1 = 0;
	var num2 = sbDistance;
	if (sbDistance>10000000) {
		num1 = parseInt(sbDistance/5000000);
		num2 = num1 * 5000000;
	} else if (sbDistance>1000000) {
		num1 = parseInt(sbDistance/500000);
		num2 = num1 * 500000;
	} else if (sbDistance>100000) {
		num1 = parseInt(sbDistance/50000);
		num2 = num1 * 50000;
	} else if (sbDistance>10000) {
		num1 = parseInt(sbDistance/5000);
		num2 = num1 * 5000;
	} else if (sbDistance>1000) {
		num1 = parseInt(sbDistance/500);
		num2 = num1 * 500;
	} else if (sbDistance>100) {
		num1 = parseInt(sbDistance/50);
		num2 = num1 * 50;
	} else if (sbDistance>10) {
		num1 = parseInt(sbDistance/5);
		num2 = num1 * 5;
	} else if (sbDistance>1) {
		num1 = parseInt(sbDistance/(25/100));
		num2 = num1 * (25/100);
	} else if (sbDistance>0.1) {
		num1 = parseInt(sbDistance/(25/1000));
		num2 = num1 * (25/1000);
	}
	sbDistance = num2;
	// */
	if (sbDistance > 2) {
		ScaleBarPrecision = "0";
	} else if (sbDistance > 1) {
		ScaleBarPrecision = "1";
	} else if (sbDistance > 1/10) {
		ScaleBarPrecision = "2";
	} else if (sbDistance > 1/100) {
		ScaleBarPrecision = "3";
	} else {
		ScaleBarPrecision = "4";
	}
	
	//alert(mDistance);
	return sbDistance;
}

// calculate distance to current scalebarunits
function calcDistance(mX,mY) {
	// Note: decimal are not hard coded to allow use with locales using commas instead of points.
	if (clickCount>0) {
		var mUnits = MapUnits;
		var mDistance = 0;
		var p = clickCount-1;
		var Lon1 = clickPointX[p] * Math.PI / 180;
		var Lon2 = mX * Math.PI / 180;
		var Lat1 = clickPointY[p] * Math.PI / 180;
		var Lat2 = mY * Math.PI / 180;
		var LonDist = Lon1-Lon2;
		var LatDist = Lat1-Lat2;
		if (MapUnits=="DEGREES") {
			var A = Math.pow(Math.sin(LatDist / 2),2) + Math.cos(Lat1) * Math.cos(Lat2) * Math.pow(Math.sin(LonDist /2),2);
			//var A = Math.cos(Lat1) * Math.cos(Lat2) * Math.pow(Math.sin(LonDist /2),2);
			var C = 2 * Math.asin(Math.min(1, Math.sqrt(A)));
			var D = (3963 - 13 * Math.sin((Lat1 + Lat2) / 2)) * C
			mDistance = D * 5280;
			mUnits = "FEET";
		} else {
			var xD = Math.abs(mX - clickPointX[p]);
			var yD = Math.abs(mY - clickPointY[p]);
			mDistance = Math.sqrt(Math.pow(xD,2) + Math.pow(yD,2));
		}
		
		var theDist = convertUnits(mDistance,mUnits,ScaleBarUnits);
		var u = Math.pow(10,numDecimals);
		currentMeasure = parseInt(theDist*u+(5/10))/u;
		
		updateMeasureBox();
		
	}
}

// convert the amounts to new units
function convertUnits(theDist1,mUnits,sUnits) {
	// Note: decimal are not hard coded to allow use with locales using commas instead of points.	
	var theDist = parseFloat(theDist1);
	var mDistance = theDist;
	//alert(theDist);
	if (mUnits == "FEET") {
		if (sUnits=="MILES") {
			mDistance = theDist / 5280;
		} else if (sUnits == "METERS") {
			mDistance = theDist * (3048/10000);
		} else if (sUnits == "KILOMETERS") {
			mDistance = theDist * (3048/10000000);
		}
	} else {
		if (sUnits=="MILES") {
			mDistance = theDist * (6213711922/10000000000000);
		} else if (sUnits == "FEET") {
			mDistance = theDist * (3280839895/1000000000);
		} else if (sUnits == "KILOMETERS") {
			mDistance = theDist / 1000;
		}
	}
	var u = Math.pow(10,numDecimals);
	//alert(u);
	if (!isNav) mDistance = parseInt(mDistance * u + (5/10)) / u
	//alert(mDistance);
	return mDistance;
}

// set new map extent 
function setExtent(newLeft, newTop, newRight, newBottom) {
	eLeft = newLeft;
	eTop = newTop;
	eRight = newRight;
	eBottom = newBottom;
}

//  set new full extent 
function setFullExtent(maxLeft, maxTop, maxRight, maxBottom) {
	fullLeft = maxLeft;
	fullTop = maxTop;
	fullRight = maxRight;
	fullBottom = maxBottom;
	fullWidth = Math.abs(fullRight-fullLeft);
	fullHeight = Math.abs(fullTop-fullBottom);
}

function beforeMapRefresh() {
 // add any code for checking parameters before map update
 // called by sendXML() before writing XML request
 //alert("Yup. It works.[1]");
}
 
function afterMapRefresh() {
 // add any code for checking parameters after map update
 // called by processXML() if XMMmode=1 after image and extent is updated
 //alert("Yup. It works.[1]"); 
}	

// zoom using button.
//		zoomType: 1=in; 2=out
function zoomButton(zoomType) {
	saveLastExtent();
	if (zoomType == 1) {
		// zoom in
		eLeft = eLeft + (xHalf/2);
		eRight = eRight - (xHalf/2);
		eTop = eTop - (yHalf/2);
		eBottom = eBottom + (yHalf/2);
	}
	else {
		// zoom out
		eLeft = eLeft - xHalf;
		eRight = eRight + xHalf;
		eTop = eTop + yHalf;
		eBottom = eBottom - yHalf;
	}
	checkFullExtent();
	//var theString = writeXML();
	sendMapXML();
}

// pan using arrow buttons
function panButton(panType) {
	//alert("Left:" + left + "\nTop:" + top + "\nRight:" + right + "\nBottom:" + bottom + "\nWidth:" + xDistance + "\nHeight:" + yDistance + "\nPanX:" + panX + "\nPanY:" + panY);
	saveLastExtent();
	xDistance = Math.abs(eRight-eLeft);
	yDistance = Math.abs(eTop-eBottom);
	panX = xDistance * panFactor;
	panY = yDistance * panFactor;
	switch(panType) {
	//if (panType == 1) {
	case 1:
		//west
		eLeft = eLeft - panX;
		eRight = eLeft + xDistance;
		break
	case 2:
		// north
		eTop = eTop + panY;
		eBottom = eTop - yDistance;
		break
	case 3:
		// east
		eRight = eRight + panX;
		eLeft = eRight - xDistance;
		break
	case 4:
		// south
		eBottom = eBottom - panY;
		eTop = eBottom + yDistance;
		break
	case 5:
		// southwest
		eTop = eTop - panY;
		eLeft = eLeft - panX;
		eBottom = eTop - yDistance;
		eRight = eLeft + xDistance;
		break
	case 6:
		// northwest
		eTop = eTop + panY;
		eLeft = eLeft - panX;
		eBottom = eTop - yDistance;
		eRight = eLeft + xDistance;
		break
	case 7:
		// northeast
		eTop = eTop + panY;
		eLeft = eLeft + panX;
		eBottom = eTop - yDistance;
		eRight = eLeft + xDistance;
		break
	case 8:
		// southeast
		eTop = eTop - panY;
		eLeft = eLeft + panX;
		eBottom = eTop - yDistance;
		eRight = eLeft + xDistance;
	}
	checkFullExtent();
	//alert("Left:" + left + "\nTop:" + top + "\nRight:" + right + "\nBottom:" + bottom + "\nWidth:" + xDistance + "\nHeight:" + yDistance + "\nPanX:" + panX + "\nPanY:" + panY);
	//var theString = writeXML();
	sendMapXML();
	
}

function checkFullExtent() {
	if (enforceFullExtent) {
		var xDistance1 = eRight - eLeft;
		var yDistance1 = eTop - eBottom;

		if (xDistance1>fullWidth) xDistance1 = fullWidth;
		if (yDistance1>fullHeight) yDistance1 = fullHeight;

		//alert("Adjusting extent to image proportions");
		if ((eLeft < limitLeft) && (eTop > limitTop)) {
			eLeft = limitLeft;
			eRight = limitRight;
		} else {
			if (eLeft < limitLeft) {
				eLeft = limitLeft;
				eRight = eLeft + xDistance1;
			} else if (eRight > limitRight) {
				eRight = limitRight;
				eLeft = eRight - xDistance1;
			}	
		}
		if ((eLeft < limitLeft) && (eTop > limitTop)) {
			eTop = limitTop;
			eBottom = limitBottom;
		} else {
			if (eTop > limitTop) {
				eTop = limitTop;	
				eBottom = eTop - yDistance1;
			} else if (eBottom < limitBottom) {
				eBottom = limitBottom;	
				eTop = eBottom + yDistance1;
			}	
		}
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -