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

📄 smismapcontrolie.js

📁 使用ASP.NET 2.0 (c#) 实现的gis 的地图系统
💻 JS
📖 第 1 页 / 共 4 页
字号:
	if ( currentTop > map.origin.y )
		clipTop = 0;
	else
		clipTop = map.origin.y - currentTop;
			
	if (currentRight > (map.origin.x + map.width)) 
		clipRight = (map.origin.x + map.width) - currentLeft;
	else if (currentLeft < 0)	// 圆的范围已经超出页面的左边界 
		clipRight = currentRight - currentLeft + 3;		// +3是因为要考虑圆弧本身的宽度。 
	else
		clipRight = currentRight;
		
	if (currentBottom > (map.origin.y + map.height)) 
		clipBottom = (map.origin.y + map.height) - currentTop;
	else if (currentTop < 0)	// 圆的范围已经超出页面的上边界 
		clipBottom = currentBottom - currentTop + 3;	// +3是因为要考虑圆弧本身的宽度。 
	else
		clipBottom = currentBottom;
			
	if (currentLeft > map.origin.x) 
		clipLeft = 0;
	else 
		clipLeft = map.origin.x - currentLeft;

	circle.style.clip = 'rect(' + clipTop + ' ' +  clipRight + ' ' + clipBottom + ' ' + clipLeft +')';
}

function SMISRemoveCircle(map)
{
	var circle = document.getElementById("SMISCircle");
	if(circle) { document.body.removeChild(circle);	}
	circle = null;
}
//-------------------- end of the first part ----------------------------//
function SMISDrawingPolygon(map,curPoint,polygonClosed)
{
	var line = document.getElementById("SMISLine");

	curPoint.x = Math.max(map.origin.x, Math.min(curPoint.x, map.origin.x + map.offsetWidth+2));
	curPoint.y = Math.max(map.origin.y, Math.min(curPoint.y, map.origin.y + map.offsetHeight+2));

	var offset = line.lineOffset;
	curPoint.x = curPoint.x - offset.x;
	curPoint.y = curPoint.y - offset.y;
	var tempOffset = new SMISPoint();
	tempOffset.x = map.origin.x - offset.x;
	tempOffset.y = map.origin.y - offset.y;
	if (polygonClosed){
		firstPoint = map.PointsParam.GetPoint(0);
		firstPoint.x = firstPoint.x + tempOffset.x;
		firstPoint.y = firstPoint.y + tempOffset.y;
		line.points.value = map.PointsParam.GetPolyPointsString(tempOffset) + 
				" " + curPoint.x + "," + curPoint.y + " " +
				firstPoint.x + "," + firstPoint.y;
	}else{
		line.points.value = map.PointsParam.GetPolyPointsString(tempOffset) + 
				" " + curPoint.x + "," + curPoint.y;
	}
}

function SMISRemovePolygon(map)
{
	var line = document.getElementById("SMISLine");
	if(line) { document.body.removeChild(line);	}
	line = null;
}

//***************************** End Drawing ******************************

function hideBusyFlag(mapControlID)
{
	if(mapControlID == null || typeof(mapControlID) == "undefined") { return;}
	var divLoading = document.getElementById(mapControlID+"_divLoading");
	if( divLoading != null && divLoading.style != null){
		divLoading.style.visibility = "hidden";
		divLoading.style.zIndex = "-1";
	}
}

function showBusyFlag(mapControlID)
{
	if(mapControlID == null || typeof(mapControlID) == "undefined") { return;}
	var divLoading = document.getElementById(mapControlID+"_divLoading");
	if( divLoading != null && divLoading.style != null){
		divLoading.style.zIndex = "999";
		divLoading.style.visibility = "visible";
	}
}

function SetMapAbsPosition(mapID)
{
	// offset 为内部元素定位所需要的相对偏移量 //
	// origin 为绝对座标 //
	var mapControl = document.getElementById(mapID.replace("_MVIMAGE",""));
	var map = document.getElementById(mapID);

	map.origin = SMISGetAbsolutePosition(map);
	map.offset = SMISGetOffsetPosition(mapControl);
	if(mapControl.style.position != "absolute"){
		map.offset.x=0;
		map.offset.y=0;
	}
}

// for layerControl 
function CheckVisibleAll(layerControlID)
{
	//LayerControl1:LayerCount
	//LayerControl1:V0
	var layerCount = eval(document.getElementById(layerControlID + ":LayerCount").value);
	var layerVisible;
	for(var i=0; i<layerCount; i++){
		layerVisible = document.getElementById(layerControlID + ":V" + i);
		if(layerVisible && !layerVisible.disabled) { layerVisible.checked = event.srcElement.checked; }
	}
}

function CheckQueryableAll(layerControlID)
{
	//LayerControl1:LayerCount
	//LayerControl1:Q0
	var layerCount = eval(document.getElementById(layerControlID + ":LayerCount").value);
	var layerQueryable;
	for(var i=0; i<layerCount; i++){
		layerQueryable = document.getElementById(layerControlID + ":Q" + i);
		if(layerQueryable) { layerQueryable.checked = event.srcElement.checked; }
	}
}

function SMISPrintMap(mapControlClientID, mapControlPage, printControlPage, mapUrl, imageHandlerEnabled)
{
	if( !mapControlClientID || !mapControlPage || !printControlPage ) { return false; }
	if ( !mapUrl ) { mapUrl = document.getElementById(mapControlClientID+"_MVIMAGE").src; }
	var address = document.getElementById(mapControlClientID+"_MapServer_Address").value;
	var port	= document.getElementById(mapControlClientID+"_MapServer_Port").value;
	printUrl = printControlPage + "?Address=" + address + "&Port=" + port + "&MapControlClientID=" + mapControlClientID + "&MapControlPage=" + mapControlPage + "&ImageHandlerEnabled=" + imageHandlerEnabled;
	var printWin = window.open(printUrl, "", "resizable,toolbar,menubar,scrollbars,status" );
}

function SMISAdjustCustomDivPosition(customDivID, alignStyle)
{
	var customDiv = document.getElementById(customDivID);
	var offsetX, offsetY;
	if(typeof(customDiv) != "undefined"){
		switch(alignStyle){
			case "LeftTop":		offsetX = 0;	offsetY = 0;	break;
			case "LeftMiddle":	offsetX = 0;	offsetY = customDiv.offsetHeight / 2;	break;
			case "LeftBottom":	offsetX = 0;	offsetY = customDiv.offsetHeight;		break;
			case "CenterTop":	offsetX = customDiv.offsetWidth / 2;	offsetY = 0;	break;
			case "CenterMiddle":offsetX = customDiv.offsetWidth / 2;	offsetY = customDiv.offsetHeight / 2;	break;
			case "CenterBottom":offsetX = customDiv.offsetWidth / 2;	offsetY = customDiv.offsetHeight;		break;
			case "RightTop":	offsetX = customDiv.offsetWidth;		offsetY = 0;	break;
			case "RightMiddle":	offsetX = customDiv.offsetWidth;		offsetY = customDiv.offsetHeight / 2;	break;
			case "RightBottom":	offsetX = customDiv.offsetWidth;		offsetY = customDiv.offsetHeight;		break;
			default:			offsetX = 0;	offsetY = 0;	break;
		}
		customDiv.style.zIndex = 1000;
		customDiv.style.left = (SMISGetNumFromPixel(customDiv.style.left) - offsetX)+"px";
		customDiv.style.top = (SMISGetNumFromPixel(customDiv.style.top) - offsetY)+"px"; 
	}
}

function SMISRegisterToolControl(toolControlID, mapControlID)
{
	var input = document.getElementById(mapControlID + "_ToolControls");
	if(typeof(input) != "undefined" && input.value.indexOf(toolControlID+",") < 0){ // 防止重复注册 //
		input.value += toolControlID + ",";
	}
}

function SMISSwitchCurrentTool(map, action)
{
	var toolControl;
	var toolControlsID = map.id.replace("_MVIMAGE","") + "_ToolControls";
	var toolControls = document.getElementById(toolControlsID);
	
	if(typeof(toolControls) != "undefined" && toolControls != null)
	{
		var arrToolControls = toolControls.value.split(",");
		for(var i=0; i<arrToolControls.length; i++){
			if(arrToolControls[i] == ""){continue;}
			toolControl = document.getElementById(arrToolControls[i]);
			if(typeof(toolControl) == "object" && toolControl.ActiveSrc != "" && toolControl.InactiveSrc != ""){
				if(toolControl.ActionName == action){
					toolControl.src = toolControl.ActiveSrc;
				}
				else{
					toolControl.src = toolControl.InactiveSrc;
				}
			}
		}
	}
	toolControl = null;
	toolControls = null;
}

function show_props(obj, objName) {
   var result = "";
   for (var i in obj) {
      result += objName + "." + i + " = " + obj[i] + "\n";
   }
   return result;
} 

function SMISGetAbsolutePosition(element, tagName, pos)
{
	var _i=0, _j=0;
	var __DEBUG	= false;
	if(typeof(pos) == "undefined" || pos == null){
		pos = new SMISPoint(0, 0);
	}
	
	while ( ! (element == null || element.tagName == "BODY" || element.tagName.toLowerCase() == tagName) ){
		_i+=1;
		
		pos.x += eval(element.offsetLeft);
		pos.y += eval(element.offsetTop);	

		var bFlag = typeof(element.style.borderLeftWidth) != "unknown";
		if(bFlag && element.style.borderLeftWidth != null && element.style.borderLeftWidth != ""){
			pos.x += SMISGetNumFromPixel(element.style.borderLeftWidth);
			pos.y += SMISGetNumFromPixel(element.style.borderTopWidth);

			if(__DEBUG) alert( "bFlag true & borderLeftWidth is not null. \n pos.Y = " + pos.y);
		}
				
		if(__DEBUG)	alert("current element id = " + element.id + "\n current element tagName = " + element.tagName);
		if(__DEBUG)	if(element.offsetParent != null) alert(element.offsetParent.tagName + "," + element.offsetLeft);

		element = element.offsetParent;
	}
	return pos;
}

//The point object
function SMISPoint(x,y)
{
	this.x = parseInt(x);
	this.y = parseInt(y);
}

//Get Current Mouse Absolute Position
function SMISGetMouseAbsolutePosition()
{
    var e=event;
    var posX=0; var posY=0;
    if(e.pageX){
        posX=e.pageX;
        posY=e.pageY;
    }
    else if(e.clientX){
        if(document.documentElement){
            posX=e.clientX+document.documentElement.scrollLeft;
            posY=e.clientY+document.documentElement.scrollTop;
        }
        else if(document.body){
            posX=e.clientX+document.body.scrollLeft;
            posY=e.clientY+document.body.scrollTop;
        }
    }
    return new SMISPoint(posX,posY);
}

//获取鼠标相对于地图的相对位置。 //
function SMISGetMouseMapRelativePosition(map)
{
	var x = 0, y = 0;
    
    if(event.offsetX != null && map.id == event.srcElement.id){ //IE6
        x = event.offsetX;
        y = event.offsetY;
    }
    else if(event.layerX != null && map.id == event.target.id){ //Firefox
        x = event.layerX;
        y = event.layerY;
    }
    else{   //Others
        var mouseAbsPosition=SMISGetMouseAbsolutePosition();
        if(map.origin){
	        x = mouseAbsPosition.x - map.origin.x;
	        y = mouseAbsPosition.y - map.origin.y;
	    }
	    else{
	        var absPosition = SMISGetAbsolutePosition(map);
            x = mouseAbsPosition.x - absPosition.x;
            y = mouseAbsPosition.y - absPosition.y;
            absPosition = null;
        }
        mouseAbsPosition = null;
    }

	return new SMISPoint(x,y);
}

function SMISGetNumFromPixel(str)
{
	if(typeof(str) == "undefined" || str == null || str == ""){return 0;}

	var strResult;
	strResult = str.toString();
	try{
		// 1 pt = 4/3 px; 1 in = 72 pt = 96 px; 
		if(strResult.indexOf("pt") > 0){
			strResult = strResult.replace("pt", "");
			strResult = eval(strResult) * 4.0 / 3.0;
		}
		else if(strResult.indexOf("in") > 0){
			strResult = strResult.replace("in", "");
			strResult = eval(strResult) * 96;
		}
		else{
			strResult = strResult.replace("px", "");
			strResult = eval(strResult);
		}
	}catch(e){alert("error:" + e + ";strResult=" + strResult);}

	return strResult;
}

function SMISGetInnerMap(object)
{
	var _map = null;
	if (object.map) {
		_map = object.map;
	} else {
		_map = object;
	}
	return _map;
}

//Create input hidden field, if exists, then update its value.
function SMISCreateHiddenField(theform, id, name, value)
{
	var _elem = document.getElementById(id);
	if(_elem == null){
		_elem = document.createElement("<input />");
		_elem.type = "hidden";
		_elem.id = id;
		_elem.name = name;
		_elem.value = value;
		theform.appendChild(_elem);
	}
	else{
		_elem.name = name;
		_elem.value = value;
	}
	return _elem;
}

function SMISPointsParam()
{
	this.Points = new Array();
	this.AddPoint = SMISPointsParamAddPoint;
	this.GetPoint = SMISPointsParamGetPoint;
	this.GetPolyPointsString = SMISGetPolyPointsString;
	this.GeneratePointsString = SMISGeneratePointsString;

	//format:x,y x,y .......................
	function SMISGetPolyPointsString(offset)
	{
		var pointString = "";
		for (i = 0; i < this.Points.length; i++) {
			if(i>0){pointString += " ";}
			pointString += (this.Points[i].x + offset.x) + "," + (this.Points[i].y + offset.y);
		}
		return pointString;
	}

	//format: numofpoints,x y,x y,...........
	function SMISGeneratePointsString()
	{
		var pointString = "" + this.Points.length + ",";
		for (i = 0; i < this.Points.length; i++) {
			if (i>0) {	pointString += ",";	}
			pointString += this.Points[i].x + " " + this.Points[i].y;		
		}
		return pointString;	
	}
}

function SMISPointsParamAddPoint(x,y)
{
	this.Points[this.Points.length] = new SMISPoint(x,y);
}

function SMISPointsParamGetPoint(indx)
{
	if (this.Points[indx] != null) {
		return new SMISPoint(this.Points[indx].x, this.Points[indx].y);
	} 
	else{
		return null;
	}
}

function SMISCreatePolygon(mapId, points)
{
	var pointsValue = SMISExtractPoints(points);
	var map = SMISGetMap(mapId);
	var mapDiv = document.getElementById(mapId);
	var editPolygonId = "SMISEditPolygon";
	var line = document.getElementById(editPolygonId);
	if (!line){
		SMISEnableVML();
		line = document.createElement("<v:polyline points=\"0,0\"/>");
		line.style.position = "absolute";
		line.style.visibility = "visible";
		line.id = editPolygonId;

⌨️ 快捷键说明

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