• 大小: 24KB
    文件类型: .cs
    金币: 1
    下载: 0 次
    发布日期: 2021-05-11
  • 语言: C#
  • 标签: ArcEngine  动态移动  

资源简介

用了多种方法,实现了在地图上定时移动某点(可以代表一辆汽车)的方法,有IElement方法,也有内存图层方法.

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.MapControl;
using ESRI.ArcGIS.ToolbarControl;
using ESRI.ArcGIS.SystemUI;
using ESRI.ArcGIS.Output;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.DataSourcesGDB;
namespace VehicleMove
{
    public partial class frmMain : Form
    {
        double dx = 116.315691;
        double dy = 39.991964;
        IActiveView pactiveview;
        public frmMain()
        {
            InitializeComponent();
            //
            timer1.Enabled = false;
            timer2.Enabled = false;
            timer3.Enabled = false;
            timer4.Enabled = false;
            timer5.Enabled = false;
            //
            this.axToolbarControl1.SetBuddyControl(this.axMapControl1);
            pactiveview = this.axMapControl1.ActiveView;
        }
        //方法1:缺点:有拖尾除非每次刷新,但是刷新会出现不停闪烁   
        private void timer1_Tick(object sender EventArgs e)
        {
            dx = dx + 0.001;
            dy = dy - 0.0001;
            MoveCar();
        }
        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@“E:\layers\2.bmp“);
            psymbol.Size = 15;
            psymbol.Angle = 270;

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

            ppoint = new PointClass();
            ppoint.PutCoords(dxdy);
            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;
        }
        pr

评论

共有 条评论