📄 aimscommon.js
字号:
// aimsCommon.js
/*
* JavaScript template file for ArcIMS HTML Viewer
* dependent on aimsXML.js, ArcIMSparam.js, aimsMap.js
*/
aimsCommonPresent=true;
var legendImage="";
var modeBlurb = modeList[0];
// delimiter to be used between coordinates in strings in ArcXML request
var coordsDelimiter = " ";
// delimiter to be used between pairs of coordinates in strings in ArcXML request
var pairsDelimiter = ";";
var chkUnits=false;
var legendTemp = false;
var ovIsVisible=false;
var showBuffer = false;
var chkGeocodeLayers = false;
var isArcMapService = false;
// character used by browser in decimals - either point or comma
var decimalChar = ((("theChar is" + (10/100)).indexOf("."))==-1) ? "," : ".";
//alert("Decimal character: " + decimalChar);
/*
***************************************************************************************
Common functions
***************************************************************************************
*/
// when there is a mapservice to load, it proceeds from here
function startUp() {
if (imsURL != "") {
//alert(imsURL);
iWidth = parseInt(document.theImage.width);
iHeight = parseInt(document.theImage.height);
if (imsURL!=imsOVURL) toggleOVVisible = false;
getStartExtent();
}
}
// get the starting extent
function getStartExtent() {
if (parent.PostFrame.document.forms[0]!=null) {
var theString = '<ARCXML version="1.1">\n<REQUEST>\n<GET_SERVICE_INFO renderer="false" extensions="true" ';
if (aimsLayersPresent) {
if (LayerID.length>0) {
theString += 'fields="false" ';
} else {
theString += 'fields="true" ';
}
} else {
theString += 'fields="false" ';
}
theString += '/>\n</REQUEST>\n</ARCXML>';
var theReply="";
if (hasOVMap) {
theString = '<ARCXML version="1.1">\n<REQUEST>\n<GET_IMAGE><PROPERTIES>\n';
theString += '<IMAGESIZE height="' + i2Height + '" width="' + i2Width + '" />\n';
if (mapBackColor!="") {
theString += '<BACKGROUND color="' + mapBackColor + '" />\n';
}
theString += '</PROPERTIES>\n';
theString += '</GET_IMAGE>\n</REQUEST>\n</ARCXML>';
sendToServer(imsOVURL,theString,902);
} else {
sendToServer(imsURL,theString,3);
}
} else {
alert(msgList[2]);
}
}
// process the start extent and set up layers
function processStartExtent(theReply) {
//alert(theReply);
checkForForbiddenTags(theReply);
// check for separators in serviceinfo
var endpos = 0;
var startpos = 0;
var pos = theReply.indexOf("<SEPARATORS");
if (pos!=-1) {
startpos = theReply.indexOf("ts=",pos);
if (startpos!=-1) {
startpos += 4;
endpos = theReply.indexOf(dQuote,startpos);
pairsDelimiter = theReply.substring(startpos,endpos);
}
startpos = theReply.indexOf("cs=",pos);
if (startpos!=-1) {
startpos += 4;
endpos = theReply.indexOf(dQuote,startpos);
coordsDelimiter = theReply.substring(startpos,endpos);
}
//alert("pairsDelimiter="+pairsDelimiter+"\ncoordsDelimiter="+coordsDelimiter);
checkCoords();
}
isArcMapService = (theReply.indexOf("<LAYOUTINFO")!=-1);
//alert("isArcMapService=" + isArcMapService);
if (isArcMapService) {
if (autoAdjustForArcMapServer) {
// adjust sizes when displayed by ArcMap Server
var nasize = parseInt(NorthArrowSize)*2;
NorthArrowSize = new String(nasize);
}
}
//alert("NorthArrowSize=" + NorthArrowSize);
pos = theReply.indexOf("<MAPUNITS");
if (pos!=-1) {
startpos = theReply.indexOf("units=",pos);
if (startpos!=-1) {
startpos += 7;
endpos = theReply.indexOf(dQuote,startpos);
MapUnits = theReply.substring(startpos,endpos);
}
} else {
// if the serviceinfo did not have MAPUNITS tag and units are set to Degrees
if (MapUnits=="DEGREES") {
// if it is too big for the world. . . allow for oversize extent
// default to Feet
if ((eRight > 250) || (eTop > 150) || (eLeft < -250) || (eBottom < -150)) MapUnits="FEET";
// alert(MapUnits);
}
// if the serviceinfo doesn't have the info, allow the user to set Map Units.
setMapUnits=true;
}
MapUnits = MapUnits.toUpperCase();
if (MapUnits=="DECIMAL_DEGREES") MapUnits = "DEGREES";
if (getStartingExtent) {
pos = theReply.indexOf("<PROPERTIES");
var theXYs = getEnvelopeXYs(theReply, pos)
eLeft = theXYs[0];
eBottom = theXYs[1];
eRight = theXYs[2];
eTop = theXYs[3];
startLeft=eLeft;
startRight=eRight;
startTop=eTop;
startBottom=eBottom;
} else {
eLeft=startLeft;
eRight=startRight;
eTop=startTop;
eBottom=startBottom;
xDistance = Math.abs(eRight-eLeft);
var sFactor = xDistance / iWidth
var aspectRatio = iWidth / iHeight;
var extentRatio = (eRight-eLeft) / (eTop-eBottom);
if (extentRatio < aspectRatio) sFactor = (eTop-eBottom) / iHeight;
mapScaleFactor = sFactor;
}
if (aimsLayersPresent) {
getLayers(theReply);
if (setLayerVisible.length>0) setupLayerVisible();
}
if (aimsQueryPresent) {
if (useStoredQuery) checkStoredQueries(theReply);
} else {
useStoredQuery=false;
}
xDistance = Math.abs(eRight-eLeft);
yDistance = Math.abs(eTop-eBottom);
xHalf = xDistance/2;
yHalf = yDistance/2;
panX = xDistance * panFactor;
panY = yDistance * panFactor;
mouseX = 0;
mouseY = 0;
pixelX = xDistance/iWidth;
pixelY = yDistance/iHeight;
mapX = eLeft;
mayY = eTop;
lastLeft = eLeft;
lastRight = eRight;
lastTop = eTop;
lastBottom = eBottom;
if (hasOVMap == false) {
fullLeft = limitLeft;
fullRight = limitRight;
fullTop = limitTop;
fullBottom = limitBottom;
fullWidth = Math.abs(fullRight - fullLeft);
fullHeight = Math.abs(fullTop - fullBottom);
}
if (aimsLayersPresent) {
if ((hasTOC) && (showTOC)) {
parent.TOCFrame.document.location=appDir+"toc.htm";
}
}
if (aimsGeocodePresent) {
if (aimsRoutePresent) {
if ((useRoute) || (useReverseGeocode)) chkGeocodeLayers = true;
} else {
if (theReply.indexOf('<EXTENSION type="Geocode"')!=-1) {
//alert("Has Geocode extension");
if (useGeocode) {
chkGeocodeLayers = true;
useReverseGeocode=false;
useRoute=false;
} else {
useGeocode=false;
useReverseGeocode=false;
chkGeocodeLayers = false;
useRoute=false;
}
} else {
//alert("Main Map Service not Geocodeable");
if (imsGeocodeURL!=imsURL+"&CustomService=Geocode") {
useGeocode=true;
chkGeocodeLayers = true;
//alert("imsGeocodeURL is not imsURL");
} else {
useGeocode=false;
chkGeocodeLayers = false;
}
useReverseGeocode=false;
useRoute=false;
}
}
} else {
//alert("Geocode not available");
useGeocode=false;
useReverseGeocode=false;
chkGeocodeLayers = false;
}
//alert("chkGeocodeLayers=" + chkGeocodeLayers);
//alert("useRoute=" + useRoute + "\nuseReverseGeocode=" + useReverseGeocode);
if (parent.ToolFrame!=null) {
//alert("Refreshing toolbar");
parent.ToolFrame.document.location= appDir + "toolbar.htm";
}
hideRetrieveData();
if ((ovIsVisible) && (aimsDHTMLPresent)) {
ovIsVisible = false;
toggleOVMap();
}
if (chkGeocodeLayers) {
getGeocodeLayers();
} else {
if ((aimsQueryPresent) && (highlightedOne!="") && (queryZoom)) {
setStartQuery();
} else {
sendMapXML();
}
}
}
// request a list of available Image MapServices
function startMap() {
showRetrieveData();
if (aimsGenericPresent) {
// only if aimsGeneric.js is loaded - for generic sample
getDefaultParams()
var theText = "<GETCLIENTSERVICES/>";
sendToServer(catURL,theText,5);
} else {
startUp();
}
}
/* ************************
* Extent functions
* ************************
*/
// get the Map Image width
function getMapWidth () {
var mapFrameWidth = thePageWin.innerWidth;
if (mapFrameWidth == null) {
mapFrameWidth = thePageDoc.body.clientWidth;
}
return mapFrameWidth;
}
//get the Map Image height
function getMapHeight () {
var mapFrameHeight = thePageWin.innerHeight;
if (mapFrameHeight == null) {
mapFrameHeight = thePageDoc.body.clientHeight;
}
return mapFrameHeight;
}
function checkCurrentExtent() {
var msg = msgList[3] + eLeft + msgList[4] + eBottom + msgList[5] + eRight + msgList[6] + eTop;
var ratio1 = xDistance/fullWidth;
msg += msgList[7] + ratio1;
alert(msg);
}
/* ************************
* Mode display functions
* ************************
*/
// write out ModeFrame page
function writeModeFrame(currentMode) {
parent.ModeFrame.document.location= appDir + "ModeFrame.htm";
}
// write out Mode on dynamic layer
function writeModeLayers(currentMode) {
var content = '<font face="' + modeLayerFont + '"color="' + modeLayerShadowColor + '"size=' + modeLayerSize + '><b>' + currentMode + '</b></font>';
replaceLayerContent("theMode1",content);
content = '<font face="' + modeLayerFont + '"color="' + modeLayerColor + '"size=' + modeLayerSize + '><b>' + currentMode + '</b></font>';
replaceLayerContent("theMode2",content);
}
/* *****************************************************
* Various String manipulation Functions
* *****************************************************
*/
// swap out double quotes for single
function swapQuotes2(inText) {
var doubleQuote = dQuote;
var singleQuote = "'";
var preTemp = "";
var posTemp = "";
var nextPos = 0;
var ePos = inText.length;
var pos=9;
while (pos != -1) {
pos = inText.indexOf(dQuote);
if (pos!=-1) {
nextPos=pos+1;
preTemp = inText.substring(0,pos);
posTemp = inText.substring(nextPos,ePos);
inText = preTemp + sQuote + posTemp;
}
}
return inText;
}
function swapQuotes(inText) {
inText = inText.replace(/"/g, "'");
return inText;
}
// convert hexidecimal rgb number to delimited decimal rgb
function convertHexToDec(hexColor) {
var pos = hexColor.indexOf(",");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -