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;
                }
            }

  • 相关阅读:
    UVA 1386
    疯狂Android演讲2 环境配置
    七内部排序算法汇总(插入排序、Shell排序、冒泡排序、请选择类别、、高速分拣合并排序、堆排序)
    【iOS发展-44】通过案例谈iOS重构:合并、格式化输出、宏观变量、使用数组来存储数据字典,而且使用plist最终的知识
    jQuery选择
    一个月操作总结
    C++易vector
    oracle rac 在完成安装错误。
    NginX issues HTTP 499 error after 60 seconds despite config. (PHP and AWS)
    解决Eclipse中文乱码的方法
  • 原文地址:https://www.cnblogs.com/enjoyprogram/p/1940224.html
Copyright © 2011-2022 走看看