?? aimsclick.js
字號:
// aimsClick.js
/*
* JavaScript template file for ArcIMS HTML Viewer
* dependent on aimsXML.js, ArcIMSparam.js, aimsCommon.js, aimsMap.js,
* aimsLayers.js, aimsDHTML.js
* aimsNavigation.js
*/
aimsClickPresent=true;
var onOVArea = false;
// Global vars to save mouse position
var mouseX=0;
var mouseY=0;
var x1=0;
var y1=0;
var x2=0;
var y2=0;
var zleft=0;
var zright=0;
var ztop=0;
var zbottom=0;
var totalMeasure=0;
var currentMeasure=0;
//MeasureArea
var currentArea = 0;
//end MeasureArea
var lastTotMeasure=0;
// variables for interactive clicks
var clickCount = 0;
var clickPointX = new Array();
var clickPointY = new Array();
var clickMeasure = new Array();
// type - 1=Measure; 2=SelectLine ; 3=SelectPolygon
var clickType = 1;
var shapeSelectBuffer = false;
var panning=false;
var zooming=false;
var selectBox=false;
var blankImage = "images/map.gif";
var leftButton =1;
var rightButton = 2;
if (isNav) {
leftButton = 1;
rightButton = 3;
}
/* *****************************************************
* Point click functions
* used by Measure and Select by Line/Polygon
* *****************************************************
*/
// put a point at click and add to clickCount
function clickAddPoint() {
var theX = mouseX;
var theY = mouseY;
getMapXY(theX,theY);
clickPointX[clickCount]=mapX;
clickPointY[clickCount]=mapY;
clickCount += 1;
selectCount=0;
totalMeasure = totalMeasure + currentMeasure;
//var u = Math.pow(10,numDecimals);
//if (totalMeasure!=0) totalMeasure = parseInt(totalMeasure*u+0.5)/u;
//MeasureArea
if (clickCount > 2) {
ComputeArea();
}
else
currentArea = 0;
// end MeasureArea
clickMeasure[clickCount]=totalMeasure;
legendTemp=legendVisible;
legendVisible=false;
var theString = writeXML();
var theNum = 99;
sendToServer(imsURL,theString,theNum);
}
// zero out all clicks in clickCount
function resetClick() {
var c1 = clickCount;
clickCount=0;
clickPointX.length=1;
clickPointY.length=1;
//MeasureArea
currentArea=0;
// end MeasureArea
currentMeasure=0;
totalMeasure=0;
lastTotMeasure=0;
clickMeasure.length=1;
selectCount=0;
legendTemp=legendVisible;
legendVisible=false;
var theString = writeXML();
var theNum = 99;
//showRetrieveMap();
sendToServer(imsURL,theString,theNum);
if (toolMode==20) updateMeasureBox();
}
// remove last click from clickCount
function deleteClick() {
var c1 = clickCount;
clickCount=clickCount-1;
selectCount=0;
if (clickCount<0) clickCount=0;
if (clickCount>0) {
totalMeasure = clickMeasure[clickCount]
clickPointX.length=clickCount;
clickPointY.length=clickCount;
clickMeasure.length=clickCount;
} else {
totalMeasure=0;
clickMeasure[0]=0;
}
currentMeasure=0;
if (c1>0) {
legendTemp=legendVisible;
legendVisible=false;
var theString = writeXML();
var theNum = 99;
sendToServer(imsURL,theString,theNum);
}
}
// MeasureArea
function ComputeArea () {
var workarea = 0.0;
cai = clickCount - 1;
caj = 0;
while (caj < clickCount) {
xjyi = clickPointX[caj] * clickPointY[cai];
xiyj = clickPointX[cai] * clickPointY[caj];
xydiff = (xjyi - xiyj);
workarea = workarea+xydiff;
cai = caj;
caj = parseFloat(caj + 1);
}
units2 = invertUnits(ScaleBarUnits, MapUnits);
units2 = units2 * units2;
//workarea = Math.abs(workarea / ( 2.0 * units2) * 640); // hard-coded for SqMiles to Acres
workarea = Math.abs(workarea / ( 2.0 * units2)); // hard-coded for SqMiles
var u = Math.pow(10,numDecimals);
if (!isNav) workarea = parseInt(workarea * u + 0.5) / u
currentArea = workarea;
}
//MeasureArea return number of mapunits per scalebar unit
function invertUnits(sUnits,mUnits) {
var mDistance = 0.0;
if (mUnits == "FEET") {
if (sUnits=="MILES") {
mDistance = 5280;
} else if (sUnits == "METERS") {
mDistance = 3.280833;
} else if (sUnits == "KILOMETERS") {
mDistance = 3280.833;
}
} else { //METERS
if (sUnits=="MILES") {
mDistance = 1609;
} else if (sUnits == "FEET") {
mDistance = 0.304800609601;
} else if (sUnits == "KILOMETERS") {
mDistance = 0.000304800609601;
}
}
return mDistance;
}
// end MeasureArea
//keep track of currently selected tool, and display it to user
// set the imsMap cursor tool
function clickFunction (toolName) {
if (hasLayer("measureBox"))
hideLayer("measureBox");
switch(toolName) {
// Zooming functions
case "zoomin":
// zoom in mode
toolMode = 1;
panning=false;
selectBox=false;
if (isIE) {
document.all.theTop.style.cursor = "crosshair";
theCursor = document.all.theTop.style.cursor;
}
modeBlurb = modeList[0];
//if (useTextFrame) parent.TextFrame.document.location= appDir + "text.htm";
break
case "zoomout":
// zoom out mode
toolMode = 2;
panning=false;
selectBox=false;
if (isIE) {
document.all.theTop.style.cursor = "crosshair";
theCursor = document.all.theTop.style.cursor;
}
modeBlurb = modeList[1];
//if (useTextFrame) parent.TextFrame.document.location= appDir + "text.htm";
break
case "zoomlast":
zoomBack();
panning=false;
zooming=false;
selectBox=false;
break
case "zoomactive":
//alert(LayerExtent[ActiveLayerIndex]);
var q = LayerExtent[ActiveLayerIndex].split("|");
panning=false;
zooming=false;
selectBox=false;
//zoomToEnvelope(parseFloat(q[0]),parseFloat(q[1]),parseFloat(q[2]),parseFloat(q[3]));
var l = parseFloat(setDecimalString(q[0]));
var b = parseFloat(setDecimalString(q[1]));
var r = parseFloat(setDecimalString(q[2]));
var t = parseFloat(setDecimalString(q[3]));
var w = r-l;
var h = t-b;
// add a bit of a margin around the layer
var wm = w * (5/100);
var hm = h * (5/100);
l = l - wm;
r = r + wm;
b = b - hm;
t = t + hm;
zoomToEnvelope(l,b,r,t);
break
case "fullextent":
fullExtent();
break
// Pan functions
case "pan":
// pan mode
toolMode = 3;
zooming=false;
selectBox=false;
if (isIE) {
document.all.theTop.style.cursor = "move";
theCursor = document.all.theTop.style.cursor;
}
modeBlurb = modeList[2];
//if (useTextFrame) parent.TextFrame.document.location= appDir + "text.htm";
break
// Identify-Hyperlink functions
case "identify":
// identify mode - layer attributes - requires aimsIdentify.js
panning=false;
zooming=false;
selectBox=false;
shapeSelectBuffer = false;
if (canQuery) {
toolMode = 4;
if (isIE) {
document.all.theTop.style.cursor = "crosshair";
theCursor = document.all.theTop.style.cursor;
}
modeBlurb = modeList[3];
} else {
alert(msgList[46]);
}
//alert("Function Not Implemented");
showGeocode=false;
if (useTextFrame) parent.TextFrame.document.location= appDir + "text.htm";
hideLayer("measureBox");
break
case "identifyall":
// identify drill mode
panning=false;
zooming=false;
selectBox=false;
shapeSelectBuffer = false;
toolMode = 5;
if (canQuery) {
if (isIE) {
document.all.theTop.style.cursor = "crosshair";
theCursor = document.all.theTop.style.cursor;
}
//modeBlurb = modeList[19]; // identify all
modeBlurb = modeList[20]; // identify visible features
//modeBlurb = modeList[3]; // identify
} else {
alert(msgList[46]);
}
//alert("Function Not Implemented");
showGeocode=false;
drawSelectBoundary=false;
if (useTextFrame) parent.TextFrame.document.location= appDir + "text.htm";
hideLayer("measureBox");
break
case "hyperlink":
// hyperlink mode - requires aimsIdentify.js
var isOk = false;
var j=-1;
panning=false;
zooming=false;
selectBox=false;
shapeSelectBuffer = false;
toolMode = 15;
modeBlurb = modeList[9];
showGeocode=false;
if (useTextFrame) parent.TextFrame.document.location= appDir + "text.htm";
hideLayer("measureBox");
var isOk = checkHyperLinkLayer(ActiveLayerIndex)
if (isOk) {
if (canQuery) {
if (isIE) {
document.all.theTop.style.cursor = "crosshair";
theCursor = document.all.theTop.style.cursor;
}
} else {
alert(msgList[46]);
}
//alert("Function Not Implemented");
} else {
currentHyperLinkLayer="";
currentHyperLinkField="";
alert(msgList[47]);
}
break
case "hyperlinkany":
// hyperlink mode - requires aimsIdentify.js
var j=-1;
panning=false;
zooming=false;
selectBox=false;
shapeSelectBuffer = false;
toolMode = 30;
modeBlurb = modeList[9];
showGeocode=false;
if (useTextFrame) parent.TextFrame.document.location= appDir + "text.htm";
hideLayer("measureBox");
if (canQuery) {
if (isIE) {
document.all.theTop.style.cursor = "crosshair";
theCursor = document.all.theTop.style.cursor;
}
} else {
alert(msgList[46]);
}
//alert("Function Not Implemented");
break
// Measure-Unit function
case "measure":
panning=false;
zooming=false;
selectBox=false;
shapeSelectBuffer = false;
if (clickCount>0) {
if (totalMeasure==0) resetClick();
}
toolMode = 20;
if (isIE) {
document.all.theTop.style.cursor = "crosshair";
theCursor = document.all.theTop.style.cursor;
}
modeBlurb = modeList[12];
if (clickType==1) {
//if (useTextFrame) parent.TextFrame.location= appDir + "measure.htm";
showLayer("measureBox");
updateMeasureBox();
}
showGeocode=false;
break
case "setunits":
if (useTextFrame) {
parent.TextFrame.location = "setUnits.htm";
} else {
window.open((appDir + "setUnits.htm"),"OptionWindow","width=575,height=120,scrollbars=yes,resizable=yes");
}
break
// Graphic Selection functions
case "shape":
panning=false;
zooming=false;
selectBox=false;
shapeSelectBuffer = false;
toolMode = 21;
if (isIE) {
document.all.theTop.style.cursor = "crosshair";
theCursor = document.all.theTop.style.cursor;
}
modeBlurb = modeList[13];
showGeocode=false;
hideLayer("measureBox");
break
case "selectbox":
panning=false;
zooming=false;
// select mode - requires aimsSelect.js
if (canQuery) {
toolMode = 10;
queryTool=0;
clickCount=0;
showBuffer=false;
if (isIE) {
document.all.theTop.style.cursor = "crosshair";
theCursor = document.all.theTop.style.cursor;
}
modeBlurb = modeList[4];
} else {
alert(msgList[46]);
}
//alert("Function Not Implemented");
showGeocode=false;
if (useTextFrame) parent.TextFrame.document.location= appDir + "text.htm";
hideLayer("measureBox");
break
case "selectpoint":
panning=false;
zooming=false;
shapeSelectBuffer = false;
// select mode - requires aimsSelect.js
if (canQuery) {
toolMode = 11;
queryTool=0;
clickCount=0;
resetClick();
if (isIE) {
document.all.theTop.style.cursor = "hand";
theCursor = document.all.theTop.style.cursor;
}
modeBlurb = modeList[5];
} else {
alert(msgList[46]);
}
//alert("Function Not Implemented");
showGeocode=false;
showBuffer=false;
hideLayer("measureBox");
break
case "selectline":
panning=false;
zooming=false;
shapeSelectBuffer = false;
// select mode - requires aimsSelect.js
if (canQuery) {
toolMode = 12;
queryTool=0;
if (isIE) {
document.all.theTop.style.cursor = "crosshair";
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -