Mapxtreme2008 Asp.net實現小車移動(軌跡回放)

來源:互聯網
上載者:User

在介面上添加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;
            }
        }

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.