Mapxtreme2008 Asp.net实现小车移动(轨迹回放)
2011-03-02 22:19
537 查看
在界面上添加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;
}
}
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;
}
}
相关文章推荐
- Mapxtreme2008 Asp.net实现小车移动(轨迹回放)
- (转)ASP.Net中无法用javascript实现图片随屏幕移动的解决办法
- ASP.NET 移动控件实现模板呈现
- 类似滴滴打车,多辆小车在地图上平滑移动的实现,基于百度地图实现(轨迹已画好)
- ASP.Net中无法用javascript实现图片随屏幕移动的解决办法
- ASP.NET MVC学习笔记 -- NerdDinner实战1 -- 中文Visual Studio 2008的设置修改以实现复数表单数类名
- 类似滴滴打车,多辆小车在地图上平滑移动的实现,基于百度地图实现(无轨迹)
- ASP.NET基础教程-DataGrid表格控件-利用ItemDataBound事件实现鼠标移动到控件的某一行时改变该行的背景色
- 如何在asp.net中实现listbox item值上下移动?(转)
- ASP.Net中无法用javascript实现图片随屏幕移动的解决办法
- ASP.Net中无法用javascript实现图片随屏幕移动的解决办法
- 如何在asp.net中实现listbox item值上下移动?
- 【C#】对异步请求处理程序IHttpAsyncHandler的理解和分享一个易用性封装 【手记】走近科学之为什么明明实现了IEnumerable<T>的类型却不能调用LINQ扩展方法 【手记】手机网页弹出层后屏蔽底层的滑动响应 【手记】ASP.NET提示“未能创建类型”处理 【Web】一个非常简单的移动web消息框 【手记】解决EXCEL跑SQL遇“查询无法运行或数据库表无法打开...”
- 类似滴滴打车,多辆小车在地图上平滑移动的实现,基于百度地图实现(无轨迹)
- MapxTreme2004 ASP.NET在WEB下实现鹰眼图
- MapXtreme+Asp.net 动态轨迹(请求大神指点)
- asp.net c#实现文件的创建、移动、删除、复制
- MapxTreme2004 ASP.NET在WEB下实现地图上修改某点的地理位置-原创
- ASP.Net中无法用javascript实现图片随屏幕移动的解决办法
- 移动项目开发笔记(asp.net中Response.WriteFile()实现文件下载)