arcgis漫游

来源:互联网 发布:电视节目直播软件 编辑:程序博客网 时间:2024/04/27 16:17

  漫游的过程中需要监控鼠标在整个过程中的变化,如鼠标点击,移动等等,因此漫游的实现也需要在地图显示空间的MouseDown、MouseMove、MouseUp事件中实现,在例程中使用的PictureBox空间名为picGis,代码如下所示:
     private void picGis_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
                return;
            if (ispanning == true)
            {
                PointClass m_point=new PointClass();
                m_point.X = e.X;
                m_point.Y = e.Y;
                IPoint m_ipoint = m_MapOperate.ScreenPointToMapPoint(m_point);//将鼠标的位置坐标转换成图形坐标
                startX = m_ipoint.X;
                startY = m_ipoint.Y;
                startDragX = e.X;
                startDragY = e.Y;
            }
        }
 
        private void picGis_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
                return;
            if (ispanning==true)
            {
                // drag the image
                picGis.Image = null;
                deltaDragX = startDragX - e.X;
                deltaDragY = startDragY - e.Y;
                picGis.Invalidate();
            }
        }
 
        private void picGis_MouseUp(object sender, MouseEventArgs e)
        {
 if (e.Button != MouseButtons.Left)

                return;

            if (ispanning==true )

            {

                this.Cursor = Cursors.WaitCursor;

                PointClass m_point = new PointClass();

                m_point.X = e.X;

                m_point.Y = e.Y;

                IPoint  m_ipoint = m_MapOperate.ScreenPointToMapPoint(m_point);//记录漫游终结点的屏幕坐标并将其转换成图形坐标

                double deltaX = m_ipoint.X - startX;

                double deltaY = m_ipoint.Y - startY;

 

                //change the extent and draw

                fuzhou.MapDescription pMapDescription =m_MapOperate.getMapDescription() ;

                fuzhou.EnvelopeN pEnvelope = pMapDescription.MapArea.Extent as fuzhou.EnvelopeN;

                pEnvelope.XMax = pEnvelope.XMax - deltaX;

                pEnvelope.XMin = pEnvelope.XMin - deltaX;

                pEnvelope.YMax = pEnvelope.YMax - deltaY;

                pEnvelope.YMin = pEnvelope.YMin - deltaY;

                fuzhou.MapExtent pMapExtext = new fuzhou.MapExtent();

                pMapExtext.Extent = pEnvelope;

                pMapDescription.MapArea = pMapExtext;

                // save the map description and draw the map

                m_MapOperate.SetMapDescription( pMapDescription);

                m_MapOperate.drawMap(ref pMapDescription, picGis);
                deltaDragX = 0;
                deltaDragY = 0;
                picGis.Invalidate();
                this.Cursor = Cursors.Default;
            }
        }
本文来源【学网】网站链接是http://www.xue5.com

 

 

 

原创粉丝点击