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

转载于:https://www.cnblogs.com/enjoyprogram/archive/2011/01/20/1940224.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值