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

📄 ovmap.js

📁 WebGis基本功能展示
💻 JS
📖 第 1 页 / 共 2 页
字号:
	    var deltaX = this.newMousePixel.x - this.orgMousePixel.x;
	    var deltaY = this.newMousePixel.y - this.orgMousePixel.y;
		this.ovDiv.style.left = (this.orgLeft + deltaX) + "px";
		this.ovDiv.style.top = (this.orgTop + deltaY) + "px";
		//updated by lfcui on 03Apr2007
		var ini_main_map_x=Util.getValueOfNoPX(this.ovDiv.parentNode.parentNode.childNodes[0].style.left);
		var ini_main_map_y=Util.getValueOfNoPX(this.ovDiv.parentNode.parentNode.childNodes[0].style.top);
		//this.ovDiv.parentNode.parentNode.childNodes[0].style.left = (ini_main_map_x+deltaX*scale_test) + "px";
		//this.ovDiv.parentNode.parentNode.childNodes[0].style.top = (ini_main_map_y+deltaY*scale_test) + "px";
        Event.stop(e);
    },
    ov_mouseup: function(e){
		alert("ov_mouseup");
        if(this.ovDiv.releaseCapture) 
			this.ovDiv.releaseCapture();
		else if(window.captureEvents) 
			window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
		
		var lastMousePixel = Util.getMousePixel(e);
		var deltaX = lastMousePixel.x - this.orgMousePixel.x;
		var deltaY = lastMousePixel.y - this.orgMousePixel.y;		
		this.reLoadTiles(this.model, deltaX, deltaY, true);
        
        document.onmousemove = null
		document.onmouseup = null
        this.isDragging = false;
        Event.stop(e);
    },
    
    ov_click: function(e){
		alert("ov_click");
        this.curMousePixel = Util.getMouseRelativePixel(e, this.ovDiv);
        this.curCenterPixel = Util.getScreenPixel(this.model.getOvModel().getViewCenterCoord(), this.model.getOvModel().getZoom());
        var deltaX = this.curCenterPixel.x - this.curMousePixel.x;
        var deltaY = this.curCenterPixel.y - this.curMousePixel.y;        
        this.ovDiv.style.left = (Util.getValueOfNoPX(this.ovDiv.style.left) + deltaX) + "px";
		this.ovDiv.style.top = (Util.getValueOfNoPX(this.ovDiv.style.top) + deltaY) + "px";
        this.reLoadTiles(this.model, deltaX, deltaY, true);

        Event.stop(e);
    },
    
    
    reLoadTiles: function(model, deltaX, deltaY, isPlus){
		alert("reLoadTiles");
        var scale = Util.zoomScale(model.getOvModel().getZoom().getLevel())/Util.zoomScale(model.getZoom().getLevel());
        var orgCenterCoord = model.getViewCenterCoord();
        var curZoom = model.getZoom();
        var realDeltaX = deltaX*scale*curZoom.realMapBound.getWidth()/(curZoom.getTileCols()*TileSize);
        var realDeltaY = deltaY*scale*curZoom.realMapBound.getHeight()/(curZoom.getTileRows()*TileSize);
        if(isPlus){
            x = orgCenterCoord.x - realDeltaX
            y = orgCenterCoord.y + realDeltaY
        }
        else{
            x = orgCenterCoord.x + realDeltaX
            y = orgCenterCoord.y - realDeltaY
        }
        var newCenterCoord = new Coordinate(x, y)
        if(!newCenterCoord.isSame(orgCenterCoord)){
            model.setViewCenterCoord(newCenterCoord);            
            this.loadTiles(model.getOvModel(), this.ovMapDiv, this.ovDiv, false)
            model.controls[this.container.childNodes[0].id].paint(model);
        }
    },

	call_glide:function(layerId,dest_x_t,dest_y_t,scale_t)
	{
		alert("call_glide");
		this.reset();
		this.target=$(layerId);
		this.ini_x=Number(Util.getValueOfNoPX(this.target.style.left));
		this.ini_y=Number(Util.getValueOfNoPX(this.target.style.top));
		this.ini_x_map=Number(Util.getValueOfNoPX(this.target.parentNode.childNodes[0].style.left));
		this.ini_y_map=Number(Util.getValueOfNoPX(this.target.parentNode.childNodes[0].style.top));
		this.ini_x_main_map=Number(Util.getValueOfNoPX(this.target.parentNode.parentNode.childNodes[0].style.left));
		this.ini_y_main_map=Number(Util.getValueOfNoPX(this.target.parentNode.parentNode.childNodes[0].style.top));

		this.glide((-dest_x_t),(-dest_y_t),scale_t);

	},


	glide: function(dest_x,dest_y,scale_test)
    { 
		alert("glide");
    	if(this.target)
    	{
//    		var scale_test=2.5;
    		var coefficient=12;
    		var dist_x,dist_y;
			if(dest_y!=0 && this.y_moved != dest_y)
	    	{    		

				dist_y=(Math.max(Math.abs(this.y_moved), Math.abs(dest_y)) - Math.min(Math.abs(this.y_moved), Math.abs(dest_y)));
				
				if(dist_y< Math.abs(dest_y/coefficient))
	            {       
	                this.y_moved = dest_y ;					
	                this.control_mark=1;  

	            }
	            else
	            { 
	            	this.y_moved = this.y_moved+dest_y/coefficient;
					this.target.style.top = (this.ini_y+this.y_moved)+"px";
		            this.target.parentNode.childNodes[0].style.top = (this.ini_y_map+this.y_moved) + "px";  
                	this.target.parentNode.parentNode.childNodes[0].style.top = (this.ini_y_main_map+this.y_moved*scale_test)+"px";
		            this.control_mark=2;		            
		        }             
	                    
	        }
	    	if(dest_x!=0 && this.x_moved != dest_x)
	    	{    		
				
				dist_x=(Math.max(Math.abs(this.x_moved), Math.abs(dest_x)) - Math.min(Math.abs(this.x_moved), Math.abs(dest_x)));
				
	            if(this.control_mark==1||dist_x< Math.abs(dest_x/coefficient))
	            {       
	                this.x_moved = dest_x ; 
	                this.control_mark=1; 
					before_move=new Date();
	            }
	            else
	            {   
		            this.x_moved = this.x_moved+dest_x/coefficient;		           
					this.target.style.left = (this.ini_x+this.x_moved)+"px";	
		            this.target.parentNode.childNodes[0].style.left = (this.ini_x_map+this.x_moved) + "px";  		            
		            this.target.parentNode.parentNode.childNodes[0].style.left = (this.ini_x_main_map+this.x_moved*scale_test) + "px";        
					this.control_mark=2;
		        }           
	                    
	        }   
	        
	        //timer control
	        if(this.control_mark==2)
	        {
				this.glide_timer=setTimeout(function() { this.glide(dest_x,dest_y,scale_test) }.bind(this), 1);
	        }
	        else if(this.control_mark==1)
	        { 
				
	        	this.target.style.left = (this.ini_x+dest_x) + "px";	
				this.target.style.top = (this.ini_y+dest_y)+"px";	
				this.target.parentNode.childNodes[0].style.left = (this.ini_x_map+this.x_moved) + "px";   
                this.target.parentNode.childNodes[0].style.top = (this.ini_y_map+this.y_moved)+"px";
                this.target.parentNode.parentNode.childNodes[0].style.left = (this.ini_x_main_map+this.x_moved*scale_test) + "px";   
                this.target.parentNode.parentNode.childNodes[0].style.top = (this.ini_y_main_map+this.y_moved*scale_test)+"px";
                this.target.parentNode.removeChild(document.getElementById("rect_temp"));
	        	clearTimeout(this.glide_timer); 
                this.reset();
	        }
			else
			{
				if(document.getElementById("rect_temp"))
					this.target.parentNode.removeChild(document.getElementById("rect_temp"));
			}
			if(this.control_mark<2)
			{
				setTimeout(function(){ this.reLoadTiles(this.model, -dest_x, -dest_y, false) }.bind(this), 1);
			}
			this.control_mark=0; 
	        dist_x=0;
	        dist_y=0;
		}        
    },
    
    reset: function()
    {		
		alert("reset");
		this.x_moved=0;
		this.y_moved=0;
		this.ini_x=0;
		this.ini_y=0;
		this.ini_x_map=0;
		this.ini_y_map=0; 
		this.ini_x_main_map=0;
		this.ini_y_main_map=0;  
		this.target=null;   
		this.control_mark=0; 
		this.glide_timer=null;
    }    
});

⌨️ 快捷键说明

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