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

  1. 客户端前台页面
  2.  
  3. <asp:ScriptManager ID="ScriptManager1" runat="server" />
  4.  
  5. <%--该js方法写在scriptmanager之后,防止出现Sys未定义错误--%>
  6. <script type="text/javascript">
  7. //获取pagerequestmanager实例后添加事件
  8. //在因同步回发或因异步回发而刷新页面上所有内容后触发
  9. Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(TrackPlayBack);
  10.  
  11. //轨迹回放函数
  12. function TrackPlayBack()
  13. {
  14. var myInput1 = document.getElementById("input1");//用来存放X坐标的控件
  15. var myInput2 = document.getElementById("input2");
  16. if(myInput1 != null && myInput2 != null)
  17. {
  18. var pointX = myInput1.value.toString();//地图上X坐标点
  19. var pointY = myInput2.value.toString();//地图上Y坐标点
  20. if(pointX != "" && pointY != "")
  21. {
  22. var mapImage = document.getElementById("MapControl1_Image");//获取地图控件
  23. if(mapImage != null)
  24. {
  25. //传递URL数据
  26. var url = "MapController.ashx?Command=TrackPlayBack&PointX=" + pointX +"&PointY=" + pointY
  27. + "&MapAlias=" + mapImage.mapAlias + "&Width=" + mapImage.width +"&Height=" + mapImage.height
  28. + "&ExportFormat=" + mapImage.exportFormat + "&Ran=" + Math.random();
  29.  
  30. //使用Ajax局部刷新更新地图
  31. var xmlHttp = CreateXMLHttp();
  32. xmlHttp.open("GET",url,false);
  33. xmlHttp.send();
  34. mapImage.src = url;
  35. }
  36. }
  37. }
  38. }
  39. </script>
  40.  
  41. <cc1:MapControl ID="MapControl1" runat="server" Width="" Height="" ExportFormat="Jpeg" MapAlias="Map1"/>
  42.  
  43. <asp:UpdatePanel ID="UpdatePanel1" runat="server">
  44. <ContentTemplate>
  45. <input id="input1" runat="server" type="text" style="width:200;" />
  46. <input id="input2" runat="server" type="text" style="width:200;" />
  47.  
  48. <input id="input3" runat="server" type="text" style="width:200;" />
  49. </ContentTemplate>
  50. <Triggers>
  51. <asp:AsyncPostBackTrigger ControlID="Timer1" />
  52. </Triggers>
  53. </asp:UpdatePanel>
  54.  
  55. <asp:Timer ID="Timer1" runat="server" Enabled="true" Interval=""
  56. ontick="Timer1_Tick" />
  1. 客户端中调用的自定义服务器MapBaseCommand
  2. /// <summary>
  3. /// 轨迹回放
  4. /// </summary>
  5. [Serializable]
  6. public class TrackPlayBack : MapBaseCommand
  7. {
  8. private Catalog myCatalog = MapInfo.Engine.Session.Current.Catalog;
  9. /// <summary>
  10. /// 动画回放图层别名
  11. /// </summary>
  12. private string animationName = "动画回放";
  13. /// <summary>
  14. /// 动画回放图元Style
  15. /// </summary>
  16. private MapInfo.Styles.BitmapPointStyle trackBmpPointStyle = new MapInfo.Styles.BitmapPointStyle("TRUC1-32.BMP", MapInfo.Styles.BitmapStyles.NativeSize, System.Drawing.Color.Blue, );
  17.  
  18. public TrackPlayBack(string _animationName, MapInfo.Styles.BitmapPointStyle _trackBmpPointStyle)
  19. {
  20. Name = "TrackPlayBack";
  21.  
  22. animationName = _animationName;
  23. trackBmpPointStyle = _trackBmpPointStyle;
  24. }
  25.  
  26. public override void Process()
  27. {
  28. //获取分站坐标
  29. double pointX, pointY;
  30. double.TryParse(HttpContext.Current.Request["PointX"].ToString(), out pointX);
  31. double.TryParse(HttpContext.Current.Request["PointY"].ToString(), out pointY);
  32. //获取实现与执行各种操作的MapContorlModel实例
  33. MapControlModel myCtrlModel = MapControlModel.GetModelFromSession();
  34. try
  35. {
  36. //获取地图实例
  37. Map myMap = myCtrlModel.GetMapObj(MapAlias);
  38. if(myMap != null)
  39. {
  40. //清空地图轨迹回放图元
  41. MapInfo.Data.Table myTable = myCatalog.GetTable(animationName);
  42. if(myTable != null)
  43. {
  44. #region 清空图元
  45. SearchInfo mySearchInfo = MapInfo.Data.SearchInfoFactory.SearchWhere("");
  46. IResultSetFeatureCollection myIRetFeaColl = myCatalog.Search(myTable, mySearchInfo);
  47. if(myIRetFeaColl != null)
  48. {
  49. foreach(Feature myObj in myIRetFeaColl)
  50. {
  51. myTable.DeleteFeature(myObj);
  52. }
  53. }
  54. #endregion
  55.  
  56. #region 添加图元
  57. MapInfo.Geometry.Point myPoint = new MapInfo.Geometry.Point(myMap.GetDisplayCoordSys(), new MapInfo.Geometry.DPoint(pointX, pointY));
  58.  
  59. Feature myFeature = new Feature(myTable.TableInfo.Columns);
  60. myFeature.Geometry = myPoint;
  61. myFeature.Style = trackBmpPointStyle;
  62.  
  63. myTable.InsertFeature(myFeature);
  64. #endregion
  65. }
  66. }
  67. }
  68. finally
  69. {
  70. System.IO.MemoryStream ms = myCtrlModel.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat);
  71. StreamImageToClient(ms);
  72. }
  73.  
  74. }
  75. }
  1. 后台代码
  2.  
  3. //此处使用Timer模拟生成的点作为动态轨迹的坐标点
  4. protected void Timer1_Tick(object sender, EventArgs e)
  5. {
  6. double pointX = + myRandom.NextDouble() * ;
  7. double pointY = pointX;
  8.  
  9. this.input1.Value = pointX.ToString();
  10. this.input2.Value = pointY.ToString();
  11. }

问题:该功能采用异步更新图元位置,并设置Timer的Interval为50ms(甚至更小),使用IE浏览器坐标点更新速度1-3次/s,使用搜狗浏览器坐标点的更新速度则更慢。怎么样才能使更新速度更快,问题出在何处?是MapXtreme异步更新本身的问题吗?

MapXtreme+Asp.net 动态轨迹(请求大神指点)的更多相关文章

  1. MapXtreme+Asp.net 动态轨迹

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

  2. 自己封装了一个EF的上下文类.,分享一下,顺便求大神指点

    using System; using System.Collections.Generic; using System.Configuration; using System.Data; using ...

  3. 耐克的定制页用canvas如何实现....跪求前端大神指点。

    选择鞋子的鞋底 鞋底会变色,也可以添加自己定制的id,这个东西看的是用canvas做的,但是小弟确实不知道怎么去做,求大神指点一二,不胜感激! nike的定制页地址:http://store.nike ...

  4. 真想用c#开发个 wp五笔输入法。。。奈何网上资料太少,源码都是c++写的。求大神指点!!!

    真想用c#开发个 wp五笔输入法...奈何网上资料太少,源码都是c++写的.求大神指点!!!!

  5. 求C#开发大神指点职业规划或者开发路数(以后怎么走),谢谢

    背景:作为一名Asp.net Web类的开发人员,工作时间有点长,5年不到,属于是天赋不太强,但是比较努力型的人,开发过程中那事情基本上都会,各种前后端框架也会使用.目前在研究分布式缓存应用 Memc ...

  6. 读FCL源码系列之List<T>---让你知其所以然---内含疑问求大神指点

    序言 在.NET开发中,List<T>是我们经常用到的类型.前段时间看到其他部门小伙伴讨论“两个List(10W个元素)集合求并集,list1.Where(p=>list2.Cont ...

  7. VS2012+SQL2008+ODBC编程,第一篇博客,写的不好忘各位大神指点一二~

    近期写一个数据库的课程设计,用的是C++ MFC .最開始用的是ADO技术,可是苦于网上大部分的教程都是VC6.0的,对着教程敲了4,5遍还是执行不成功.我用的IDE是VS2012,毕竟VC6.0和V ...

  8. WebSocket在ASP.NET MVC4中的简单实现 (该文章转自网络,经尝试并未实现,请大神指点。)

    WebSocket 规范的目标是在浏览器中实现和服务器端双向通信.双向通信可以拓展浏览器上的应用类型,例如实时的数据推送.游戏.聊天等.有了WebSocket,我们就可以通过持久的浏览器和服务器的连接 ...

  9. 请求大神,C#如何截取字符串中指定字符之间的部分 按指定字符串分割 一分为二 c# 去除字符串中的某个已知字符

    string stra = "abcdefghijk";string strtempa = "c";string strtempb = "j" ...

随机推荐

  1. sql语句查询列的说明

    SELECT C.name,value FROM sys.columns C INNER JOIN sys.tables T ON C.object_id = T.object_idINNER JOI ...

  2. 代理模式与Android

    代理模式(Proxy) 一.   什么是代理模式 先来看看官方的说法,代理模式就是为其它对象提供一种代理,以控制对这个对象的訪问. 看来这个官方的说法的确有点官方,看了还是让人感觉不点不知所措,还是不 ...

  3. WSockExpert[抓包工具]

    一.WSockExpert简单介绍          WSockExpert是一个抓包工具,它能够用来监视和截获指定进程网络数据的传输,对測试站点时非常实用.在黑客的手中,它经常被用来改动网络发送和接 ...

  4. asp.net mvc3 数据验证(四)—Remote验证的一个注意事项

    原文:asp.net mvc3 数据验证(四)-Remote验证的一个注意事项         前几篇把asp.net mvc3 中基于Model的主要数据验证的方法都已经讲完了,本节纯粹只是讲一个我 ...

  5. ASP.NET如何显示农历时间

    ASP.NET如何显示农历时间 CS部分代码如下: 代码如下: public string ChineseTimeNow = "";  public string ForignTi ...

  6. 安卓CTS官方文档之兼容性方案概览

    兼容性方案概览 安卓的兼容性方案让安卓手机生产商能够很容易就开发中可兼容的安卓设备(天地会珠海分舵注:可兼容什么呢?就是可以兼容标准google提供的安卓系统可以支持的功能,以防手机生产商把开源的安卓 ...

  7. 《互联网初创企业password》书评

    今天试用了一下<互联网初创企业password>这本书.我觉得这本书开始的很真实,从学校刚毕业那会儿.它是生命,他们的牛b时间,一直想做点什么来证明自己.具体地,并且现在是在最好的时候.互 ...

  8. 【C#版本详情回顾】C#3.0主要功能列表

    隐式类型的本地变量和数组 在与本地变量一起使用时,var 关键字指示编译器根据初始化语句右侧的表达式推断变量或数组元素的类型 对象初始值设定项 支持无需显式调用构造函数即可进行对象初始化 集合初始值设 ...

  9. Julia is a high-level, high-performance dynamic programming language for technical computing, with syntax that is familiar to users of other technical

    http://julialang.org/ julia | source | downloads | docs | blog | community | teaching | publications ...

  10. The Decoder - UVa458

    欢迎访问我的新博客:http://www.milkcu.com/blog/ 原文地址:http://www.milkcu.com/blog/archives/uva458.html 题目描述  The ...