Mapxtreme2008 asp.net realizes trolley movement (track playback)

Source: Internet
Author: User
Tags time interval

Add a Timer control to the interface, and then add the timer's tick to the UpdatePanel1 trigger (implement a timed partial refresh map), set a time interval, and add the following code to the event:

protected void Timer1_Tick (object sender, EventArgs e)
{/* The following code can realize the dynamic movement of the point, on the basis of the original point longitude offset 0.5 each time
Catalog cat = MapInfo.Engine.Session.Current.Catalog;

MapInfo.Data.Table tbl = MapInfo.Engine.Session.Current.Catalog.GetTable ("Animation");
if (tbl!= null)
{
Location of the update point
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 ();
*/

Move an entity to a specified position, that is, to achieve track playback

First in the interface design, in the ListBox1 and ListBox2 to add 8 points of the coordinates, in the timer to achieve dynamic movement to these eight points position
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);
The location of the//update point
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;
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.