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

📄 aimsdb.js

📁 采用arcims结合asp开发的一个webgis系统,针对地下水,实现了曲线时时绘制的功能.
💻 JS
字号:
// extended db javascript template for ArcIMS HTML Viewer
// aimsDB.js
/*
*  JavaScript template file for ArcIMS HTML Viewer
*		dependent on aimsXML.js, ArcIMSparam.js, aimsCommon.js, aimsMap.js, and aimsLayers.js
*		To be interactive, dependent also on aimsDHTML.js, aimsClick.js, and aimsNavigation.js
*/

// global variables
var aimsDBPresent = true;

var theDBFrame = parent.DBFrame.document;
var dbLinkLayer = "Parcels";
var dbLinkLayerID = "2";
var dbLinkLayerIndex = 1;
ActiveLayerIndex = dbLinkLayerIndex;
var dbQueryString = "";
var dbIdString = "";
var dbIdValue = "";
var dbNumValue = "";
var dbStreetValue = "";
var dbOwnerValue = "";
var dbDisplayValue = "";

// set the active layer parameters to the dbLinkLayer
function matchDBLinkLayer(layerName) {
	var j = -1;
	for (var i=0;i<layerCount;i++) {
		if (LayerName[i]==layerName) j = i;
	}
	if (j>-1) {
		dbLinkLayerIndex = j
		dbLinkLayerID = LayerID[dbLinkLayerIndex];
		dbLinkLayer = LayerName[dbLinkLayerIndex];
		ActiveLayerIndex = dbLinkLayerIndex;
		ActiveLayer = dbLinkLayerID;
	}
}

// db Identify - external db access
//	XMLMode=70... response will be sent to parseIDFieldData()
function dbIdentify(e) {
	highlightedOne="";
	var theX = mouseX;
	var theY = mouseY;
	getMapXY(theX,theY);
	searchTolerance = (xDistance/iWidth) * pixelTolerance;
	//alert(xDistance + "/" + iWidth + "/" + pixelTolerance + "/" + searchTolerance);
	var tempWest = mapX - searchTolerance;
	var tempNorth = mapY + searchTolerance;
	var tempEast = mapX + searchTolerance;
	var tempSouth = mapY - searchTolerance;
	var theString = writeGetFeatures(tempWest,tempSouth,tempEast,tempNorth);
	//alert(theString);
	showRetrieveData();
	sendToServer(imsQueryURL,theString,70);
}

// get the attribute values from the identify XML response
// 	then send request to external db access server
// 	and request for map highlighting feature
function parseIDFieldData(theReply) {
	//alert(theReply);
	var fList="";
	var iList="";
	var fieldPair = "";
	var fieldString = mapIDField + "=";
	var idString = LayerIDField[dbLinkLayerIndex] + "=";
	//alert(fieldString);
	var qpos = 0;
	var pos = theReply.indexOf("<FEATURECOUNT count=");
	var startpos = pos + 21;
	var endpos = theReply.indexOf(dQuote,startpos);
	var tempString = theReply.substring(startpos,endpos);
	//alert(tempString);
	var featureCount = parseInt(tempString);
	if (featureCount > 0) {
		endpos = 1;
		for (var i=0;i<featureCount;i++) {
			var startpos2 = theReply.indexOf("<FIELDS ",endpos);
			pos = startpos2 + 8;
			qpos = fieldString.length + 1;
			startpos =theReply.indexOf(fieldString,pos);
			startpos = startpos + qpos
			endpos = theReply.indexOf(dQuote,startpos);
			tempString = theReply.substring(startpos,endpos);
			if (addIDQuotes) {
				tempString = '"' + tempString + '"';
			}
			if (i>0) tempString = "," + tempString;
			fList = fList + tempString;
			
			pos = startpos2 + 8;
			qpos = idString.length + 1;
			startpos =theReply.indexOf(idString,pos);
			startpos = startpos + qpos
			endpos = theReply.indexOf(dQuote,startpos);
			tempString = theReply.substring(startpos,endpos);
			//tempString = LayerIDField[dbLinkLayerIndex] + " = " + tempString;
			if (i>0) tempString = "," + tempString;
			iList = iList + tempString;
			
		}
		
		var featureString = "select " + dbFieldList + " from " + dbTableList + " where " + dbIDField + " IN (" + fList + ") order by " + dbIDField;
		
		writeDBResponsePage(featureString);
		if (highlightIdentify) {
			//alert(iList);
			highlightedOne=LayerIDField[dbLinkLayerIndex] + " IN (" + iList + ")";
			sendMapXML();
		}
	} else {
		tempString = ActiveLayer + ":\n" + dbList[0];
		//alert(tempString);
		var Win1;
		if ((useExternalWindow) || (!useTextFrame)) {
			Win1 = window.open("","QueryWindow","width=575,height=120,scrollbars=yes,resizable=yes");
		} else {
			Win1 = parent.TextFrame.document;
			Win1.open();
		}
		Win1.writeln('<html><meta http-equiv="Content-Type" content="text/html; charset=' + charSet + '"><head>');
		Win1.writeln('	<title>' + dbList[1] + '</title>');
		Win1.writeln('</head>');
		Win1.writeln('<body BGCOLOR="White" TEXT="Black" LEFTMARGIN=0 TOPMARGIN=0>');
		Win1.writeln('<FONT FACE="Arial"><B>' + LayerName[ActiveLayerIndex] + '</B></font><FONT FACE="Arial" size="-2">');
		Win1.writeln('<br>' + dbList[2] + '</FONT>');
		Win1.writeln('</body></html>');
		Win1.close();
	}
	hideRetrieveData();
	
}

function getDBQuery(value) {
	var queryString = "";
	queryString = mapIDField + " IN (" + value + ")";
	setQueryString=  queryString ;
	hideRetrieveData();
	var theString = getDBEnvelope(queryString);
	sendDBXMLRequest(theString, 3001)
}

function getDBQuery2(value1,value2) {
	// for vb implementation
	var queryString = "";
	queryString = mapIDField + " IN (" + value1 + ")";
	setQueryString=  queryString ;
	dbQueryString = dbIDField + " IN (" + value1 + ") AND " + dbDisplayField + " = '" + value2 + "'";
	dbQueryString = "select " + dbFieldList + " from " + dbTableList + " where " + dbQueryString + " order by " + dbIDField;
	hideRetrieveData();
	var theString = getDBEnvelope(queryString);
	sendDBXMLRequest(theString, 3001)
}

// create the ArcXML query request with feature id
//	used to match external db record to feature. . .
// 	envelope will parsed from response
function getDBEnvelope(queryString) {
	var theFields = LayerIDField[dbLinkLayerIndex] + " " + LayerShapeField[dbLinkLayerIndex];
	
	var theString = '<ARCXML VERSION="1.1">\n<REQUEST>\n<GET_FEATURES outputmode="xml" geometry="false" envelope="true"';
	theString += ' compact="true" featurelimit="' + maxFeaturesReturned + '" beginrecord="' + queryStartRecord + '">\n';
	theString += '<LAYER id="' + LayerID[dbLinkLayerIndex] + '" ftype="' + ActiveLayerType + '" />';
	if (useLimitExtent) {
		// keep this within the limitExtent
		theString += '<SPATIALQUERY subfields="' + theFields + '" where="' + queryString + '" />';
		theString += '<SPATIALFILTER relation="area_intersection">\n';
		theString += '<ENVELOPE maxx="' + limitRight + '" maxy="' + limitTop + '" minx="' + limitLeft + '" miny="' + limitBottom + '" />\n';
		theString += '</SPATIALFILTER>\n';
		theString += '</SPATIALQUERY>\n';
	} else {
	theString += '<QUERY subfields="' + theFields + '" where="' + queryString + '" />';
	}
	theString += '</GET_FEATURES>';
	theString += '</REQUEST>';
	theString += '</ARCXML>';
	//alert("writeQueryXML()\nQuery XML Request:\n" + theString);
	selectLayer=ActiveLayer;
	selectType=ActiveLayerType;
	selectCount=0;
	hightlightedOne="";
	selectPoints.length=1;
	selectLeft.length=1;
	selectRight.length=1;
	selectTop.length=1;
	selectBottom.length=1;
	return theString;

}

// after matching feature to external db record
// 	parse out envelope and send zoom to envelope request.
function parseDBEnvelope(theReply) {
	var theError = getXMLErrorMessage(theReply);
	var featureCount = justGetFeatureCount(theReply);
	var theXYs = getEnvelopeXYs(theReply, 0)
	var endpos = 0;
	selectLeft[0] = theXYs[0];
	selectBottom[0] = theXYs[1];
	selectRight[0] = theXYs[2];
	selectTop[0] = theXYs[3];
	endpos = xmlEndPos;
	var inData = parseRecordString(theReply, endpos);
	endpos = xmlEndPos;
	var selectedData = clearLeadingSpace(inData);
	var fName1 = getFieldNames(selectedData);
	var fValue1 = getFieldValues(selectedData);
	selectPoints[0] = getIdValue(fName1, fValue1);
	highlightedOne = LayerIDField[ActiveLayerIndex] + " = " + selectPoints[0];
	//alert(selectLeft[selNum] + "," + selectRight[selNum]);
	var fWidth = selectRight[0] - selectLeft[0];
	var fHeight = selectTop[0] - selectBottom[0];
	var mWMargin = 0;
	var mHMargin = 0;
	if (selectType=="point") {
		mWMargin = fullWidth * selectPointMargin;
		mHMargin = fullHeight * selectPointMargin;
	} else {
		mWMargin = fWidth * selectMargin;
		mHMargin = fHeight * selectMargin; 
	}
	saveLastExtent();
	eLeft = selectLeft[0] - mWMargin;
	eRight = selectRight[0] + mWMargin;
	eTop = selectTop[0] + mHMargin;
	eBottom = selectBottom[0] - mHMargin;
		//alert(highlightedOne);
	legendTemp=legendVisible;
	legendVisible=false;
	sendMapXML();

}

// dynamically write out page with form that automatically submits upon loading. . .
// 	sends request to external db access module with sql query
function writeDBResponsePage(featureString) {
	//alert(dbSQLurl);
	var theFrame = "TextFrame";
	if ((useExternalWindow) || (!useTextFrame)) theFrame = "_blank";
	var Win1 = parent.DBFrame.document;
	var startpos = featureString.indexOf("IN (");
	startpos += 4;
	var endpos = featureString.indexOf(")",startpos);
	if (endpos==-1) endpos = featureString.length;
	var flist = featureString.substring(startpos, endpos);

	theForm = Win1.forms[0];
	theForm.IDValue.value = flist;
	theForm.DisplayValue.value = "**None**";
	theForm.submit();
	
	featureString=null;
	Win1 = null;
	
}


// Custom function to send ArcXML requests
//	points response to processDBXML()
function sendDBXMLRequest(XMLRequest, theType) {
	var theFunction = "parent.MapFrame.processDBXML";
	sendCustomToServer(XMLRequest,theFunction, theType)
}

// Custom XML processor for db access
function processDBXML(theReplyIn) {
	theReplyIn = replacePlus(theReplyIn);
	var theReply = unescape(theReplyIn);
	//alert(theReply);
	okToSend = true;
	if (debugOn>2) alert(msgList[13] + theReply);
	if (XMLMode == 3001) {
		//alert("XMLMode=3001");
		// parse out envelope and send zoom to envelope request.
		parseDBEnvelope(theReply);
	
	}
	if (XMLMode == 3002) {
		alert("XMLMode=3002");
		
	
	}
}

⌨️ 快捷键说明

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