arcgis二次开发动态追踪以及提高

  前几天呢,想做动态追踪,发现这篇文章(https://blog.csdn.net/anlidengshiwei/article/details/41545301)写的不错,功能实现了之后,感觉可以更好,所有就自己就试着写了一下,本人新手,还望大家多多包涵;

第一种方法,小车点的行进路径该有鼠标动态获取;  

        double[] arrx=new double[1000];
        double[] arry=new double[1000];
        int i = 0;
        private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            arrx[i] = e.mapX;
            arry2[i] = e.mapY;
            i++;
        }

这是鼠标点击事件事件,获取用来获取点的坐标,

 private void timer1_Tick(object sender, EventArgs e)
        {
            if (s < i)
            {
                dx = arrx[s];
                dy = arry2[s];
                MoveCar();
                s++;
            }
            else {
                this.timer1.Dispose();
                MessageBox.Show("走完了");
               
            }
          
           
        }

这是对控件time1的处理

private void MoveCar()
        {
            //得到当前活动范围  

            IActiveView pActiveView = axMapControl1.ActiveView;
            //开始画笔   
            pActiveView.ScreenDisplay.StartDrawing(pActiveView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            IPoint ppoint;
            IGeometry pgeo;
            IPictureMarkerSymbol psymbol = new PictureMarkerSymbolClass();
            IRgbColor prgbcolor = new RgbColorClass();
            prgbcolor.Red = 0;
            prgbcolor.Green = 0;
            prgbcolor.Blue = 0;

            psymbol.BitmapTransparencyColor = prgbcolor;
            psymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, @"C:\Users\deng\Desktop\毕业设计\NodeAnimation\Command1.bmp");
            psymbol.Size = 15;
            psymbol.Angle = 270;

            //ISimpleMarkerSymbol psimplesymbol = new SimpleMarkerSymbolClass();  
            //psimplesymbol.Size = 10;  
            //psimplesymbol.Color = (IColor)prgbcolor;  

            ppoint = new PointClass();
            ppoint.PutCoords(dx, dy);
            pgeo = ppoint;

            pActiveView.ScreenDisplay.SetSymbol((ISymbol)psymbol);
            pActiveView.ScreenDisplay.DrawPoint(ppoint);
            //结束画笔  
            pActiveView.ScreenDisplay.UpdateWindow();
            pActiveView.ScreenDisplay.FinishDrawing();
            //System.Object obj = psymbol;  
            //this.axMapControl1.DrawShape(pgeo, ref obj);  

            //this.axMapControl1.CenterAt(ppoint);  
            IEnvelope penv = this.axMapControl1.Extent;
            penv.CenterAt(ppoint);
            this.axMapControl1.Extent = penv;
        }
这是主要方法,与我之前学习的文章相同.
 private void toolStripButton1_Click(object sender, EventArgs e)
        {
            this.timer1.Enabled = true;
            this.timer1.Interval = 1000;     
        }

这是启动运行的方法

 int s = 0;
        double dx = 112.906;
        double dy = 27.912;
        IActiveView pactiveview;  
        public Form1()
        {
            InitializeComponent();
            timer1.Enabled = false;
            this.axToolbarControl1.SetBuddyControl(this.axMapControl1);
            pactiveview = this.axMapControl1.ActiveView;  
        }
运行之后可以在地图点击多个点,在点击
toolStripButton1

这个控件就会按照我们所选的位置行动

源码

https://download.csdn.net/download/qq_27380923/10373709

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值