MapXtreme+Asp.net 动态轨迹
MapXtreme+Asp.net 动态轨迹(请求大神指点)
功能简介:在MapXtreme+Asp.net的环境下实现轨迹回放功能,经过两天的努力基本实现此功能。但还有部分问题需要解决,求大神们指点迷津,问题会在结尾处提出。

客户端前台页面
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<%--该js方法写在scriptmanager之后,防止出现Sys未定义错误--%>
<script type="text/javascript">
//获取pagerequestmanager实例后添加事件
//在因同步回发或因异步回发而刷新页面上所有内容后触发
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(TrackPlayBack);
//轨迹回放函数
function TrackPlayBack()
{
var myInput1 = document.getElementById("input1");//用来存放X坐标的控件
var myInput2 = document.getElementById("input2");
if(myInput1 != null && myInput2 != null)
{
var pointX = myInput1.value.toString();//地图上X坐标点
var pointY = myInput2.value.toString();//地图上Y坐标点
if(pointX != "" && pointY != "")
{
var mapImage = document.getElementById("MapControl1_Image");//获取地图控件
if(mapImage != null)
{
//传递URL数据
var url = "MapController.ashx?Command=TrackPlayBack&PointX=" + pointX +"&PointY=" + pointY
+ "&MapAlias=" + mapImage.mapAlias + "&Width=" + mapImage.width +"&Height=" + mapImage.height
+ "&ExportFormat=" + mapImage.exportFormat + "&Ran=" + Math.random();
//使用Ajax局部刷新更新地图
var xmlHttp = CreateXMLHttp();
xmlHttp.open("GET",url,false);
xmlHttp.send();
mapImage.src = url;
}
}
}
}
</script>
<cc1:MapControl ID="MapControl1" runat="server" Width="800" Height="600" ExportFormat="Jpeg" MapAlias="Map1"/>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<input id="input1" runat="server" type="text" style="width:200;" />
<input id="input2" runat="server" type="text" style="width:200;" />
<input id="input3" runat="server" type="text" style="width:200;" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" />
</Triggers>
</asp:UpdatePanel>
<asp:Timer ID="Timer1" runat="server" Enabled="true" Interval="50"
ontick="Timer1_Tick" />


客户端中调用的自定义服务器MapBaseCommand类
/// <summary>
/// 轨迹回放
/// </summary>
[Serializable]
public class TrackPlayBack : MapBaseCommand
{
private Catalog myCatalog = MapInfo.Engine.Session.Current.Catalog;
/// <summary>
/// 动画回放图层别名
/// </summary>
private string animationName = "动画回放";
/// <summary>
/// 动画回放图元Style
/// </summary>
private MapInfo.Styles.BitmapPointStyle trackBmpPointStyle = new MapInfo.Styles.BitmapPointStyle("TRUC1-32.BMP", MapInfo.Styles.BitmapStyles.NativeSize, System.Drawing.Color.Blue, 24); public TrackPlayBack(string _animationName, MapInfo.Styles.BitmapPointStyle _trackBmpPointStyle)
{
Name = "TrackPlayBack"; animationName = _animationName;
trackBmpPointStyle = _trackBmpPointStyle;
} public override void Process()
{
//获取分站坐标
double pointX, pointY;
double.TryParse(HttpContext.Current.Request["PointX"].ToString(), out pointX);
double.TryParse(HttpContext.Current.Request["PointY"].ToString(), out pointY);
//获取实现与执行各种操作的MapContorlModel实例
MapControlModel myCtrlModel = MapControlModel.GetModelFromSession();
try
{
//获取地图实例
Map myMap = myCtrlModel.GetMapObj(MapAlias);
if(myMap != null)
{
//清空地图轨迹回放图元
MapInfo.Data.Table myTable = myCatalog.GetTable(animationName);
if(myTable != null)
{
#region 清空图元
SearchInfo mySearchInfo = MapInfo.Data.SearchInfoFactory.SearchWhere("");
IResultSetFeatureCollection myIRetFeaColl = myCatalog.Search(myTable, mySearchInfo);
if(myIRetFeaColl != null)
{
foreach(Feature myObj in myIRetFeaColl)
{
myTable.DeleteFeature(myObj);
}
}
#endregion #region 添加图元
MapInfo.Geometry.Point myPoint = new MapInfo.Geometry.Point(myMap.GetDisplayCoordSys(), new MapInfo.Geometry.DPoint(pointX, pointY)); Feature myFeature = new Feature(myTable.TableInfo.Columns);
myFeature.Geometry = myPoint;
myFeature.Style = trackBmpPointStyle; myTable.InsertFeature(myFeature);
#endregion
}
}
}
finally
{
System.IO.MemoryStream ms = myCtrlModel.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat);
StreamImageToClient(ms);
} }
}


后台代码 //此处使用Timer模拟生成的点作为动态轨迹的坐标点
protected void Timer1_Tick(object sender, EventArgs e)
{
double pointX = 4999 + myRandom.NextDouble() * 2;
double pointY = pointX; this.input1.Value = pointX.ToString();
this.input2.Value = pointY.ToString();
}

问题:该功能采用异步更新图元位置,并设置Timer的Interval为50ms(甚至更小),使用IE浏览器坐标点更新速度1-3次/s,使用搜狗浏览器坐标点的更新速度则更慢。怎么样才能使更新速度更快,问题出在何处?是MapXtreme异步更新本身的问题吗?
MapXtreme+Asp.net 动态轨迹的更多相关文章
- MapXtreme+Asp.net 动态轨迹(请求大神指点)
功能简介:在MapXtreme+Asp.net的环境下实现轨迹回放功能,经过两天的努力基本实现此功能.但还有部分问题需要解决,求大神们指点迷津,问题会在结尾处提出. 客户端前台页面 <asp:S ...
- asp.net 动态添加自定义控件
前两天一直纠结asp.net动态添加控件后,后台获取不到控件的问题,查看了网上很多的回答,可能自己的理解有误或者自己所掌握的知识有限,都没有解决我遇到的问题,经过两天的研究,终于把问题解决了. 我这里 ...
- asp.net动态输出透明gif图片
要使用asp.net动态输出透明gif图片,也就是用Response.ContentType = "image/GIF". 查了国内几个中文资料都没解决,最后是在一个英文博客上找到 ...
- ASP.NET 动态编译、预编译和 WebDeployment 项目(转)
概述 在 Web 服务器上,既可以部署源文件,也可以部署编译后程序集. 若部署源文件,则当用户访问时,Web 应用程序会被动态编译,并缓存该程序集,以便下次访问. 否则,若部署程序集,Web 应用程序 ...
- ASP.NET动态的网页增删查改
动态页面的增删查改,不多说了,直接上代码 跟前面的一般处理程序一样我上用的同一套三层,只是UI层的东西不一样,在纠结着要不要重新在上一次以前上过的代码: 纠结来纠结去,最后我觉得还上上吧,毕竟不上为我 ...
- VC动态轨迹画线
分类: 2.4 线程/图形学2010-04-30 22:14 1878人阅读 评论(0) 收藏 举报 文档null 这是一个绘制直线的简单绘图程序,能过实现动态轨迹画线,在拖动时产生临时线来表示可能画 ...
- asp.net动态加载ascx用户控件
原文:asp.net动态加载ascx用户控件 在主aspx/ascx文件中,将目标ascx1,ascx2控件拖拉到其页面中,然后删除,目的是要生成:Register 代码,然后在主文件中定义DIV或T ...
- asp.net动态网站repeater控件使用及分页操作介绍
asp.net动态网站repeater控件使用及分页操作介绍 1.简单介绍 Repeater 控件是一个容器控件,可用于从网页的任何可用数据中创建自定义列表.Repeater 控件没有自己内置的呈现功 ...
- asp.net动态为网页添加关键词的代码
如下资料是关于asp.net动态为网页添加关键词的代码,希望能对小伙伴们有较大用.HtmlMeta keywords = new HtmlMeta();keywords.Name = "ke ...
随机推荐
- linux open
一直记住不打开文件时候的mode,今天发现原来可以直接用0644这样的八进制数字代替,好开森 #include <stdio.h> #include <sys/types.h> ...
- Asp.Net MVC5入门学习系列⑤
原文:Asp.Net MVC5入门学习系列⑤ 检查VS生产的编辑方法和编辑窗体 前面我们一步使用强类型,然后创建Controller(控制器)的时候,VS默认已经给我们把CURD都简单的实现了.这篇的 ...
- 纯CSS3打造七巧板
原文:纯CSS3打造七巧板 最近项目上要制作一个七巧板,脑子里瞬间闪现,什么...七巧板不是小时候玩的吗... 七巧板的由来 先来个科普吧,是我在查资料过程中看到的,感觉很有意思. 宋朝有个叫黄伯思的 ...
- Windows 7硬盘安装CentOS 6.4 双系统 (WIN7硬盘安装Linux(Fedora 16,CentOS 6.2,Ubuntu 12.04))
WIN7下硬盘安装Linux(Fedora 16,CentOS 6.2.Ubuntu 12.04) 近期在看<鸟哥私房菜:基础学习篇>.认为非常不错,想要用U盘装个windows 7 和 ...
- SQL点滴9—SQL Server中的事务处理以及SSIS中的内建事务
原文:SQL点滴9-SQL Server中的事务处理以及SSIS中的内建事务 我们可以把SSIS中的整个package包含在一个事务中,但是如果在package的执行过程中有一个表需要锁定应该怎么处理 ...
- OCP-1Z0-051-题目解析-第13题
13. View the Exhibit and examine the structure of the PRODUCTS table. You need to generate a report ...
- js关闭当前页面不弹出提示的方法
js关闭当前页面不弹出提示的方法 js关闭当前页面不弹出提示的方法 "window.opener=null;window.open('','_self','');window.close() ...
- Scala从零开始:使用Intellij IDEA写hello world
Scala从零开始:使用Intellij IDEA写hello world 分类: Scala |2014-05-23 00:39 |860人阅读 引言 在之前的文章中,我们介绍了如何使用Scal ...
- cocos2d-x的TestCpp分析
最近,我刚开始学coco2d-x 我会写我的学习经验来 首先TestCppproject有许多例子文件夹,而在这些文件夹以外的其他文件 .我首先研究这些文件: controller.h/cpp:管理方 ...
- 【工作笔记一】【转】Visual Studio 2012常用快捷键总结
Visual Studio 2012常用快捷键总结 原文 http://blog.csdn.net/yl2isoft/article/details/9886379 写在前面: 都知道,合理使用 ...