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

📄 supermap.is.action.js

📁 地理信息系统方面的开发源码
💻 JS
字号:
//========================================================================== 
// SuperMap IS 客户端程序,版权所有,北京超图地理信息技术有限公司,2000-2006。 
// 本程序只能在有效的授权许可下使用。未经许可,不得以任何手段擅自使用或传播。 
// 作者:			SuperMap IS Team 
// 修改:	 
// 文件名:			SuperMap.IS.Action.js  
// 功能:			AjaxMap Action 相关接口   
// 最后修改时间:	2006-05-23 
//========================================================================== 

SuperMap.IS.Action=function()
{
    this.type="Action";
    
    this.Init=function(mapControl){this.mapControl=mapControl;};
    this.Destroy=function(){this.mapControl=null;};
    
    this.OnClick=function(e){};
    this.OnDblClick=function(e){};
    this.OnMouseMove=function(e){};
    this.OnMouseDown=function(e){};
    this.OnMouseUp=function(e){};
    this.OnContextMenu=function(e){};
}

SuperMap.IS.ZoomInAction=function()
{
    this.type="ZoomInAction";

    var mapDiv=null;
	var zoomRect=null;
	var _cx=0,_cy=0,_nx=0,_ny=0;
	var originX=0;originY=0;
	var actionStarted=false;
	this.Init=function(mapControl){
	    this.mapControl=mapControl;
	    mapDiv=mapControl.mapDiv;
		if(ygPos.browser=="ie"){mapControl.container.style.cursor="images/cursors/ZoomIn.cur";}else{mapControl.container.style.cursor="crosshair";};
		zoomRect=$('zoomRect');
		if(!zoomRect){
		    zoomRect=document.createElement("div");
		    zoomRect.className="zoomRect";
		    _Hide();
//    		_AddEvent(zoomRect,"onmouseup",_OnMouseUp);
    		mapDiv.appendChild(zoomRect);
		}
	};
	this.Destroy=function(){/*_RemoveEvent(zoomRect,"onmouseup",_OnMouseUp);*/mapDiv.removeChild(zoomRect);mapDiv=null;this.mapControl=null;};
	function _OnMouseDown(e){
	    actionStarted=true;
	    originX=e.pixelCoord.x-e.offsetCoord.x;originY=e.pixelCoord.y-e.offsetCoord.y;
		_cx=_nx=e.offsetCoord.x;_cy=_ny=e.offsetCoord.y;
//		_Draw(_cx,_cy,1,1);_Show();
	}
	function _OnMouseMove(e){
	    if(!actionStarted){return;}
		_nx=e.offsetCoord.x;_ny=e.offsetCoord.y;
		_Draw(_Min(_cx,_nx),_Min(_cy,_ny),_Max(1,_Abs(_nx-_cx)),_Max(1,_Abs(_ny-_cy)));_Show();
	}
	function _OnMouseUp(e){
   	    actionStarted=false;
		if(_Abs(_cx-_nx)>1&&_Abs(_cy-_ny)>1){
			var param=this.mapControl.GetMapParam();
			param.SetPixelRect(new SuperMap.IS.PixelRect(originX+_cx,originY+_cy,originX+_nx,originY+_ny));
			this.mapControl.SetMapParam(param);
		}
		else{
			this.mapControl.SetCenterAndZoom(e.mapCoord.x, e.mapCoord.y, this.mapControl.GetZoomLevel()+1);
		}
		_Hide();
	}
	function _Draw(x,y,width,height){_SetPosAndSize(zoomRect,x,y,width,height);}
	function _SetPosAndSize(el,x,y,width,height){el.style.left=x+"px";el.style.top=y+"px";el.style.width=width+"px";el.style.height=height+"px";}
	function _Show(){zoomRect.style.display="block";}
	function _Hide(){zoomRect.style.display="none";}
	this.OnMouseDown=_OnMouseDown;this.OnMouseMove=_OnMouseMove;this.OnMouseUp=_OnMouseUp;
}

SuperMap.IS.ZoomOutAction=function()
{
    this.type="ZoomOutAction";
    var mapDiv=null;
	var zoomRect=null;
	var _cx=0,_cy=0,_nx=0,_ny=0;
	var originX=0;originY=0;
	var actionStarted=false;
	this.Init=function(mapControl){
		this.mapControl=mapControl;
		mapDiv=mapControl.mapDiv;
		if(ygPos.browser=="ie"){mapControl.container.style.cursor="images/cursors/ZoomOut.cur";}else{mapControl.container.style.cursor="crosshair";};
		zoomRect=$('zoomRect');
		if(!zoomRect){
		    zoomRect=document.createElement("div");
		    zoomRect.className="zoomRect";
		    _Hide();
//    		_AddEvent(zoomRect,"onmouseup",_OnMouseUp);
    		mapDiv.appendChild(zoomRect);
		}
	};
	this.Destroy=function(){/*_RemoveEvent(zoomRect,"onmouseup",_OnMouseUp);*/mapDiv.removeChild(zoomRect);mapDiv=null;this.mapControl=null;};
	function _OnMouseDown(e){
	    actionStarted=true;
	    originX=e.pixelCoord.x-e.offsetCoord.x;originY=e.pixelCoord.y-e.offsetCoord.y;
		_cx=_nx=e.offsetCoord.x;_cy=_ny=e.offsetCoord.y;
//		_Draw(_cx,_cy,1,1);_Show();
	}
	function _OnMouseMove(e){
	    if(!actionStarted){return;}
		_nx=e.offsetCoord.x;_ny=e.offsetCoord.y;
		_Draw(_Min(_cx,_nx)+2,_Min(_cy,_ny)+2,_Max(5,_Abs(_nx-_cx))-4,_Max(5,_Abs(_ny-_cy))-4);_Show();
	}
	function _OnMouseUp(e){
   	    actionStarted=false;
		if(_Abs(_cx-_nx)>1&&_Abs(_cy-_ny)>1){
			var param=this.mapControl.GetMapParam();
			// width=curWidth*curWidth/rectWidth; height...
			// center=rectCenter;
			var tpr=new SuperMap.IS.PixelRect(originX+_cx,originY+_cy,originX+_nx,originY+_ny);
			var	pr=new SuperMap.IS.PixelRect();pr.Copy(tpr);
			var mapSize=this.mapControl.GetSize();
			var width=mapSize.Width()*mapSize.Width()/tpr.Width();
			var height=mapSize.Height()*mapSize.Height()/tpr.Height();
			pr.leftTop.x=tpr.leftTop.x-(width-tpr.Width())/2;pr.rightBottom.x=tpr.rightBottom.x+(width-tpr.Width())/2;
			pr.leftTop.y=tpr.leftTop.y-(height-tpr.Height())/2;pr.rightBottom.y=tpr.rightBottom.y+(height-tpr.Height())/2;
			param.SetPixelRect(pr);
			this.mapControl.SetMapParam(param);
		}
		else{
			this.mapControl.SetCenterAndZoom(e.mapCoord.x, e.mapCoord.y, this.mapControl.GetZoomLevel()-1);
		}
		_Hide();
	}
	function _Draw(x,y,width,height){_SetPosAndSize(zoomRect,x,y,width,height);}
	function _SetPosAndSize(el,x,y,width,height){el.style.left=x+"px";el.style.top=y+"px";el.style.width=width+"px";el.style.height=height+"px";}
	function _Show(){zoomRect.style.display="block";}
	function _Hide(){zoomRect.style.display="none";}
	this.OnMouseDown=_OnMouseDown;this.OnMouseMove=_OnMouseMove;this.OnMouseUp=_OnMouseUp;
}

SuperMap.IS.PanAction=function()
{
    this.type="PanAction";
	var actionStarted=false;
    var lastMouseX,lastMouseY;
    this.Init=function(mapControl){
 	  	this.mapControl=mapControl;
		if(ygPos.browser=="ie"){mapControl.container.style.cursor="images/cursors/Pan.cur";}else{mapControl.container.style.cursor="move";};
    };
    this.Destroy=function(){this.mapControl=null;};
    function _OnMouseDown(e){
        actionStarted=true;
		lastMouseX=_GetMouseX(e);lastMouseY=_GetMouseY(e);
		if(this.mapControl.container.setCapture){this.mapControl.container.setCapture();}
	}
    function _OnMouseMove(e){
        if(!actionStarted){return;}
        var mouseX=_GetMouseX(e);var mouseY=_GetMouseY(e);
        this.mapControl.Pan(lastMouseX-mouseX,lastMouseY-mouseY);
        lastMouseX=mouseX;lastMouseY=mouseY;
    }
    function _OnMouseUp(e){
        actionStarted=false;
        this.mapControl.StopDynamicPan();
        if(this.mapControl.container.releaseCapture){this.mapControl.container.releaseCapture();}
    }
    this.OnMouseDown=_OnMouseDown;this.OnMouseMove=_OnMouseMove;this.OnMouseUp=_OnMouseUp;
};


SuperMap.IS.DrawLineAction=function()
{
    this.type="DrawLineAction";
	var actionStarted=false;
    var line=null;
    var xs=new Array();
    var ys=new Array();
    this.Init=function(mapControl){
    	this.mapControl=mapControl;
		if(ygPos.browser=="ie"){mapControl.container.style.cursor="images/cursors/PolygonQuery.cur";}else{mapControl.container.style.cursor="pointer";};
    };
    this.Destroy=function(){if(line){this.mapControl.CustomLayer.RemoveLine(line.id);line=null;}xs=null;ys=null;this.mapControl=null;};
    function _OnClick(e){
        xs.push(e.mapCoord.x);ys.push(e.mapCoord.y);
        line=this.mapControl.CustomLayer.InsertLine("drawLine",xs,ys,3,"red");
    }
    
    function _OnContextMenu(e){
    }
//    this.OnMouseDown=_OnMouseDown;this.OnMouseMove=_OnMouseMove;this.OnMouseUp=_OnMouseUp;
    this.OnClick=_OnClick;this.OnContextMenu=_OnContextMenu;
};

SuperMap.IS.PointQueryAction=function(layerNames,returnFields,tolerance)
{
    this.type="PointQueryAction";
	var _queryParam=null;
	var _layerNames=layerNames;
	var _returnFields=returnFields;
	var _tolerance=tolerance;

	this.Init=function(mapControl){
 	  	this.mapControl=mapControl;
		if(ygPos.browser=="ie"){mapControl.container.style.cursor="images/cursors/PointQuery.cur";}else{mapControl.container.style.cursor="crosshair";};

		if(!_tolerance){_tolerance=100;}
		if(!_queryParam){
			_queryParam=new SuperMap.IS.QueryParam();
			if(!_returnFields){_returnFields=["smID","Name"];}
			if(!_layerNames){
				_queryParam.queryAllLayer=true;
				_queryParam.returnFields=_returnFields;
			}else{
				_queryParam.queryLayers=new Array();
				var tempLayerNames = _layerNames.concat();
				while(tempLayerNames.length>0){
					var ql=new SuperMap.IS.QueryLayer();
					ql.layerName=tempLayerNames.pop();
					ql.returnFields=_returnFields;
					_queryParam.queryLayers.push(ql);
				}
				tempLayerNames=null;
			}
			_queryParam.expectCount = 20;
		}
    };
    this.Destroy=function(){
		this.mapControl=null;
//		if(_queryParam){_queryParam.Destroy();}_queryParam=_returnFields=null;
	};
    
    this.OnClick=function(e){
		this.mapControl.GetQueryManager().QueryByPoint(e.mapCoord, _tolerance, _queryParam);
    };
    this.OnDblClick=function(e){};
    this.OnMouseMove=function(e){};
    this.OnMouseDown=function(e){};
    this.OnMouseUp=function(e){};
    this.OnContextMenu=function(e){};
};

⌨️ 快捷键说明

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