zoukankan      html  css  js  c++  java
  • Mapxtreme2008 Asp.net实现小车移动(轨迹回放)

    在界面上添加Timer控件,然后在UpdatePanel1的Trigger中添加Timer的Tick(实现定时局部刷新地图);设定间隔时间,在事件中添加如下代码:

     protected void Timer1_Tick(object sender, EventArgs e)
        {        /*下面代码可实现点的动态移动,在原来点的基础上经度每次偏移0.5
            Catalog cat = MapInfo.Engine.Session.Current.Catalog;

            MapInfo.Data.Table tbl = MapInfo.Engine.Session.Current.Catalog.GetTable("Animation");
            if (tbl != null)
            {
                //更新点的位置
                tbl.BeginAccess(MapInfo.Data.TableAccessMode.Write);
                foreach (Feature fcar in tbl)
                {
                    fcar.Geometry.GetGeometryEditor().OffsetByXY(0.5, 0, MapInfo.Geometry.DistanceUnit.Degree, MapInfo.Geometry.DistanceType.Spherical);               
                    fcar.Geometry.EditingComplete();
                    fcar.Update();
                }
                tbl.EndAccess();
              */

    //将图元移动到指定位置,即实现轨迹回放

    //首先在界面设计时,在ListBox1与ListBox2中添加8个点的坐标,在定时器中实现动态移动到这八个点的位置
            Catalog cat = MapInfo.Engine.Session.Current.Catalog;

            MapInfo.Data.Table tbl = MapInfo.Engine.Session.Current.Catalog.GetTable("Animation");
            if (tbl != null)
            {
                int i = int.Parse(Label3.Text);
                double dbLon = double.Parse(ListBox1.Items[i].Text);
                double dbLat = double.Parse(ListBox2.Items[i].Text);
                double dbLonOff, dbLatOff;
                DPoint dpt = new DPoint(dbLon,dbLat);

                if (i == 0)
                {
                    dbLonOff = dbLon - 118.2377;
                    dbLatOff = dbLat - 36.785;
                }
                else
                {
                    dbLonOff = dbLon - double.Parse(ListBox1.Items[i-1].Text);
                    dbLatOff = dbLat - double.Parse(ListBox2.Items[i-1].Text);
                }            //更新点的位置
                tbl.BeginAccess(MapInfo.Data.TableAccessMode.Write);
                Feature fcar = MapInfo.Engine.Session.Current.Catalog.SearchForFeature(tbl, MapInfo.Data.SearchInfoFactory.SearchWhere("Name='aaaa'"));
                //fcar.Geometry.GetGeometryEditor().OffsetByXY(0.5, 0, MapInfo.Geometry.DistanceUnit.Degree, MapInfo.Geometry.DistanceType.Spherical);
                fcar.Geometry.GetGeometryEditor().OffsetByXY(dbLonOff, dbLatOff, MapInfo.Geometry.DistanceUnit.Degree, MapInfo.Geometry.DistanceType.Spherical);
                fcar.Geometry.EditingComplete();
                fcar.Update();
                tbl.EndAccess();
                i++;
                Label3.Text = i.ToString();
                if (i >= 8)
                {
                    Timer1.Enabled = false;
                }
            }

  • 相关阅读:
    pat 甲级 1065. A+B and C (64bit) (20)
    pat 甲级 1064. Complete Binary Search Tree (30)
    pat 甲级 1010. Radix (25)
    pat 甲级 1009. Product of Polynomials (25)
    pat 甲级 1056. Mice and Rice (25)
    pat 甲级 1078. Hashing (25)
    pat 甲级 1080. Graduate Admission (30)
    pat 甲级 团体天梯 L3-004. 肿瘤诊断
    pat 甲级 1099. Build A Binary Search Tree (30)
    Codeforce 672B. Different is Good
  • 原文地址:https://www.cnblogs.com/enjoyprogram/p/1940224.html
Copyright © 2011-2022 走看看