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

📄 smismapcontrolns.js

📁 supermap开发的基站管理系统
💻 JS
📖 第 1 页 / 共 4 页
字号:
		for(var j=0; j<countY; j++) {
			img = document.getElementById(mapId + "_Cells_" + (i*countY+j));	// reuse old image element.  
			if(!img) {
				img = document.createElement("IMG");
				img.id = mapId + "_Cells_" + (i*countY+j);
//				div.appendChild(img);
			}
			img.onload = function anonymous() { this.style.visibility = "visible"; };
			img.style.visibility = "hidden";
			img.src = handler + arrUrls[i*countY+j];
			with(img.style) {
				if(__DEBUG__){	border = "1px dotted blue";	}
				position = "absolute";
				var pixelLeft = cellWidth * i - offsetLT.x;
				var pixelTop = cellHeight * j - offsetLT.y;
				var pixelWidth = cellWidth;
				var pixelHeight = cellHeight;
				left = (cellWidth * i - offsetLT.x) + "px";
				top = (cellHeight * j - offsetLT.y) + "px";
				width = cellWidth+"px";
				height = cellHeight+"px";
				
				if(pixelLeft + pixelWidth < 0 || pixelTop + pixelHeight < 0 || 
					pixelLeft - map.style.pixelWidth > 0 || pixelTop - map.style.pixelHeight > 0) 
				{
					visibility = "hidden";
				}
				// window.status += "(" + i + "" + j + ":" + pixelLeft + "," + pixelTop + ")";
			}
			arrImg[arrImg.length] = img;
			
		}
	}
	img = null;
/**/if(__DEBUG__){	window.status = "ALL:" + (countX * countY);	}
	// 先显示中间的...
	var middle = Math.round(countX * countY / 2);
	var createdImg;
	var createdImgID;
	for(var i=0; i<=middle; i++) {
		createdImgID = mapId + "_Cells_" + (middle - i);
		if(__DEBUG__){ window.status += ";" + (middle - i);}
		createdImg = arrImg[middle - i];
		if(createdImg) {
			createdImg.style.visibility = ""; 
			div.appendChild(arrImg[middle - i]);
		}

		createdImgID = mapId + "_Cells_" + (middle + i);
		if(__DEBUG__){window.status += "," + (middle + i);}
		createdImg = arrImg[middle + i];
		if(createdImg) {
			createdImg.style.visibility = ""; 
			div.appendChild(arrImg[middle + i]);
		}
	}

	HideObsoleteCells(countX*countY, mapId + "_Cells_");

	if(__DEBUG__){	window.status = "ALL:" + (countX * countY);	}
	while(arrImg && arrImg.length > 0) { arrImg.pop(); }
	arrImg = null;
	div = null;
	workLayer = null;
	if(__DEBUG__ && arr.length > 7)	{
		window.status = (arr[7]);
	}
	hideBusyFlag(mapId);
	SetMVIMAGE(mapId);
}

function SMISGetWorkLayer(mapId)
{
	var workLayer = document.getElementById(mapId + "_WorkLayer");
	if(!workLayer) {
		workLayer = document.createElement("DIV");
		workLayer.id = mapId + "_WorkLayer";
		var mapDiv = document.getElementById(mapId);
		var img = document.getElementById(mapId +"_MVIMAGE");
		mapDiv.insertBefore(workLayer,img);
	}
	return workLayer;
}

function PanMapCells(map, startPoint, curPoint)
{
	if(!map) { return; }
	if(!map.MapUrlCount) { map.MapUrlCount = 1; }
	var workLayer = SMISGetWorkLayer(map.mapId);
	var container = workLayer.childNodes[0];
	map.style.left = (curPoint.x-startPoint.x)+"px";
	map.style.top = (curPoint.y-startPoint.y)+"px";
	map.style.opacity =0.5;
	with(container.style){
		if(!container.origin) { container.origin = new SMISPoint(left, top); }
		left = (container.origin.x + curPoint.x - startPoint.x) + "px";
		top = (container.origin.y + curPoint.y - startPoint.y) + "px";
	}
	return;

	var img;
	for(var i=0; i<map.MapUrlCount; i++){
		img = document.getElementById(map.id.split('_')[0] + "_Cells_" + i);
		if(!img) { continue; }
		with(img.style){
			if(!img.origin) { img.origin = new SMISPoint(pixelLeft, pixelTop); }
			pixelLeft = img.origin.x + curPoint.x - startPoint.x;
			pixelTop = img.origin.y + curPoint.y - startPoint.y;
		}
	}
	img = null;
}

function PanWorkLayer(map, startPoint, curPoint)
{
	if(!map) { return; }
	var workLayer = SMISGetWorkLayer(map.mapId);
	if(!workLayer) { return; }
	with(workLayer.style){
		if(!workLayer.origin) { workLayer.origin = new SMISPoint(pixelLeft, pixelTop); }
		pixelLeft = workLayer.origin.x + curPoint.x - startPoint.x;
		pixelTop = workLayer.origin.y + curPoint.y - startPoint.y;
	}
}

// 在CustomLayer中画线和面对象
function SMISOnCustomLayerLoad(mapControlID)
{
	var hiddenPoints=document.getElementById(mapControlID+"_pointsValue");
    var hiddenStrokes=document.getElementById(mapControlID+"_stylesValue");
    var hiddenId=document.getElementById(mapControlID+"_idValue");
    var hiddenPolygonType=document.getElementById(mapControlID+"_polygonType");
    if(!hiddenPoints||!hiddenStrokes||!hiddenPolygonType||!hiddenId)
    {
        return;
    }
    var pointsValue=hiddenPoints.value.split("&");
    var style=hiddenStrokes.value.split("&");
    var id=hiddenId.value.split("&");
    var polygonType=hiddenPolygonType.value.split("&");
    for(var i=0;i<pointsValue.length-1;i++)
    {
        SMISDrawPolygon(mapControlID,id[i],pointsValue[i],style[i],polygonType[i]);
    }
}


function SMISDrawPolygon(mapId,id,points,styleValue,closed)
{
    var pointsValue = SMISExtractPoints(points);
	var map = SMISGetMap(mapId);
	var mapDiv = document.getElementById(mapId);
	var editLineId = id;
	var line = document.getElementById(editLineId);
	if (!line){
	    var style=styleValue.split("@");
		line = document.createElement("div");
		document.forms[0].appendChild(line);
		line.style.left =map.origin.x+"px";
		line.style.top = map.origin.y+"px";
		line.style.position = "absolute";
		line.style.visibility = "visible";
		line.style.opacity=style[3]; // 通过css来控制透明度
		line.id = editLineId;
		line.style.zIndex = 1002;
		
		line.PointsParam = new SMISPointsParam();
		line.origin = map.origin;
		line.offset = map.offset;
		line.origin.x = map.origin.x;
		line.origin.y = map.origin.y;
		line.offset.x = map.offset.x;
		line.offset.y = map.offset.y;
		line.map = map;

		var Xpoints = SplitX(pointsValue);
		var Ypoints = SplitY(pointsValue);
		var jg = new jsGraphics(editLineId);
		jg.origin = map.origin;
		jg.origin.x = map.origin.x;
		jg.origin.y = map.origin.y;
		
		
		jg.setColor(style[2]);
		var pxs=SplitX(points);
		var pys=SplitY(points);
		jg.fillPolygon(pxs, pys);
		if(closed=="True") // 如果是面对象就要再画一遍边线
		{
		    jg.drawPolygon(Xpoints, Ypoints);
		    lineTemp = document.createElement("div");
	        document.forms[0].appendChild(lineTemp);
	        lineTemp.style.left =map.origin.x+"px";
	        lineTemp.style.top = map.origin.y+"px";
	        lineTemp.style.position = "absolute";
	        lineTemp.style.visibility = "visible";
	        lineTemp.style.zIndex = 1003;
	        lineTemp.id=editLineId+"Temp";
	        var hiddenId=document.getElementById(mapId+"_idValue");
	        if(hiddenId){hiddenId.value=hiddenId.value+"&"+lineTemp.id;}
	        lineTemp.PointsParam = new SMISPointsParam();
		    lineTemp.origin = map.origin;
		    lineTemp.offset = map.offset;
		    lineTemp.origin.x = map.origin.x;
		    lineTemp.origin.y = map.origin.y;
		    lineTemp.offset.x = map.offset.x;
		    lineTemp.offset.y = map.offset.y;
		    lineTemp.map = map;

	        var jgTemp = new jsGraphics(lineTemp.id);
		    jgTemp.origin = map.origin;
		    jgTemp.origin.x = map.origin.x;
		    jgTemp.origin.y = map.origin.y;
            jgTemp.setColor(style[1]);
            jgTemp.setStroke(parseInt(style[0]));
            jgTemp.drawPolyline(Xpoints, Ypoints);
            jgTemp.paint();
            SMISClipPolygon(lineTemp);
		}
		else
		{
			jg.setColor(style[1]);
			jg.setStroke(parseInt(style[0]));
			jg.drawPolyline(Xpoints, Ypoints);
		}
		jg.paint();
	}
	SMISClipPolygon(line);
}

function StartDefaultAction(map, actionName)
{
	switch(actionName){
	    // DrawRect
		case 'ZOOMIN':
		case 'ZOOMOUT':
		case 'RECTQUERY':
			map.style.cursor = 'crosshair';
			map.onmousedown	= SMISOnMouseDown;
			map.onmousemove	= SMISRectOnMouseMove;
			map.onmouseup	= SMISOnMouseUp;
			map.onclick = null;
			map.ondblclick = null;
			break;
		// Pan
		case 'PAN':
			map.style.cursor = 'move';
			map.onmousedown = SMISPanOnMouseDown;
			map.onmousemove = SMISPanOnMouseMove;
			map.onmouseup = SMISOnMouseUp;
			map.onclick = null;
			map.ondblclick = null;
			break;
		// DrawLines
		case 'MEASUREDIS':
		case 'FINDPATH':
			map.style.cursor = 'default';
			map.PolygonClosed = false;
			map.onmousedown = null;
			map.onmousemove = SMISPolygonOnMouseMove;
			map.onmouseup = null;
			map.onclick = SMISPolygonOnMouseClick;
			map.ondblclick = SMISPolygonOnDblClick;
			break;
		// DrawPolygon
		case 'MEASUREAREA':
		case 'POLYGONQUERY':
			map.style.cursor = 'default';
			map.PolygonClosed = true;
			map.onmousedown = null;
			map.onmousemove = SMISPolygonOnMouseMove;
			map.onmouseup = null;
			map.onclick = SMISPolygonOnMouseClick;
			map.ondblclick = SMISPolygonOnDblClick;
			break;
		// Click
		case 'POINTQUERY':
		case 'CLOSESTFACILITY':
			map.style.cursor = 'default';
			map.bActionStarted = true;
			map.onmousedown = null;
			map.onmousemove = null;
			map.onmouseup = SMISOnMouseUp;
			map.onclick = null;
			map.ondblclick = null;
			break;
		// DrawCircle
		case 'CIRCLEQUERY':
			map.style.cursor = 'default';
			map.onmousedown = SMISOnMouseDown;
			map.onmousemove = SMISCircleOnMouseMove;
			map.onmouseup = SMISCircleOnMouseUp;
			map.onclick = null;
			map.ondblclick = null;
			break;
	}
}

//TODO.
function RenderQuickPan(mapId, description, quickPanWidth, quickPanHeight, prefix)
{
	var mapDiv = document.getElementById(mapId);
	var theform = document.forms[0];
	var quickPanInputId = mapId + "_QuickPanInput";

	SMISCreateHiddenField(theform, quickPanInputId, quickPanInputId, "");

	var quickPanDescs = description.split(",");	// left, up, right, down
	if(!quickPanDescs) { quickPanDescs = new Array(4); }
	for(var i=4; i<quickPanDescs.length; i--) { quickPanDescs.push(""); }

	var StrDivFormat = "<div id={0} width=" + quickPanWidth + " height=" + quickPanHeight + " border=0 cellspacing=0 cellpadding=0 style='position:absolute; cursor:pointer; visibility:hidden;' title='{1}'>";
	StrDivFormat += "<img src=\"{2}\" onclick=\"document.getElementById('" + quickPanInputId + "').value='{3}'; " + mapId + "_DoPostBack();\">";
	StrDivFormat += "</div>";

	var strDivLeft = StrDivFormat.replace("{0}", mapId + "_QuickPanDiv_L");
	strDivLeft = strDivLeft.replace("{1}", quickPanDescs[0]);
	strDivLeft = strDivLeft.replace("{2}", prefix.replace("{0}", "L"));
	strDivLeft = strDivLeft.replace("{3}", "L");
	var divLeft = document.createElement("DIV");
	divLeft.innerHTML = strDivLeft;
	mapDiv.appendChild(divLeft);

	var strDivUp = StrDivFormat.replace("{0}", mapId + "_QuickPanDiv_U");
	strDivUp = strDivUp.replace("{1}", quickPanDescs[1]);
	strDivUp = strDivUp.replace("{2}", prefix.replace("{0}", "U"));
	strDivUp = strDivUp.replace("{3}", "U");
	var divUp = document.createElement("DIV");
	divUp.innerHTML = strDivUp;
	mapDiv.appendChild(divUp);

	var strDivRight = StrDivFormat.replace("{0}", mapId + "_QuickPanDiv_R");
	strDivRight = strDivRight.replace("{1}", quickPanDescs[2]);
	strDivRight = strDivRight.replace("{2}", prefix.replace("{0}", "R"));
	strDivRight = strDivRight.replace("{3}", "R");
	var divRight = document.createElement("DIV");
	divRight.innerHTML = strDivRight;
	mapDiv.appendChild(divRight);

	var strDivDown = StrDivFormat.replace("{0}", mapId + "_QuickPanDiv_D");
	strDivDown = strDivDown.replace("{1}", quickPanDescs[3]);
	strDivDown = strDivDown.replace("{2}", prefix.replace("{0}", "D"));
	strDivDown = strDivDown.replace("{3}", "D");
	var divDown = document.createElement("DIV");
	divDown.innerHTML = strDivDown;
	mapDiv.appendChild(divDown);

//	SMISMapSetPosition(mapId);
}

function MapControl_Callback(argument)
{
	var mapId = "MapControl1";
	var mapUrl = document.getElementById(mapId + "_MapUrl");
	if(!mapUrl) return;
	mapUrl.value = argument;
	var map = SMISGetMap(mapId);
	map.ImageCellsAdded = false;
	var workLayer = SMISGetWorkLayer(mapId);
	if(workLayer){
		workLayer.innerHTML = "";
	}
	AddImageCellsToWorkLayer(mapId);
//	hideBusyFlag(mapId);
    if(map.bActionStarted){
        map.bActionStarted = false;
    }
	
	map = null;
	workLayer = null;
}

function GetMouseScrollDelta(e)
{
	if(e.wheelDelta){return e.wheelDelta;}
	else if(e.detail){return -e.detail;}
	return 0;
}

function SMISOnMouseWheel(e)
{
	if(!e)e=window.event;
	var map = this;
	if(!map){return false;}
	if(map.bWheeling){return false;}
	map.bWheeling = true;
	var delta=GetMouseScrollDelta(e);
	var argument = "ZoomByPixel";
	var params = "";
	var relativePos = SMISGetMouseMapRelativePosition(event, map);
	if(delta>0){
		params = relativePos.x + "&" + relativePos.y + "&0.5";
		map.DoCallback(argument, params);
	}
	else if(delta<0){
		params = relativePos.x + "&" + relativePos.y + "&2";
		map.DoCallback(argument, params);
	}
	map.bWheeling = false;
	e.cancelBubble=true;
	return false;
}

function GetTarget(e)
{
	if(!e)e=window.event;var t=null;
	if(e.srcElement)t=e.srcElement;
	else if(e.target)t=e.target;
	if(t.nodeType==3)t=targ.parentNode;
	return t;
}

function AddOnMouseWheelFunction(mapId)
{
	//debug.
  return;
	var map = SMISGetMap(mapId);
	if(!map.DoCallback)	{ map.DoCallback = Map_DoCallback; }
	map.onmousewheel = SMISOnMouseWheel;
}

// zhangwl修改 
function SMISAddElement(element, id)
{
	var obj = document.createElement(element);
	obj.id = id;
	return(obj);
}

function HideObsoleteCells(endIndex, prefix)
{
	var start = parseInt(endIndex);
	var img;
	while(true){
		img = document.getElementById(prefix + start);
		if(!img){break;}
		img.style.visibility = "hidden";
		img.src = "images/spacer.gif";
		start++;
	}
	img = null;
}

⌨️ 快捷键说明

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