功能简介:在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="" Height="" 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=""
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, ); 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 = + myRandom.NextDouble() * ;
double pointY = pointX; this.input1.Value = pointX.ToString();
this.input2.Value = pointY.ToString();
}

问题:该功能采用异步更新图元位置,并设置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. asp.net 获得客户端 mac 地址

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...

  2. Hack 语言学习/参考---1.1 What is Hack?

    What is Hack?¶ Hack is a language for HHVM that interopates seamlessly with PHP. The barrier to entr ...

  3. 国籍控件(js源码)

    国籍控件(js源码) 一直苦于没有好的国籍控件可以用,于是抽空写了一个国籍控件,现分享给大家. 主要功能和界面介绍 国籍控件主要支持中文.英文过滤以及键盘上下事件. 源码介绍 国籍控件核心是两个文件, ...

  4. Milo的游戏开发的一些链接资料

    http://www.cnblogs.com/miloyip/default.aspx?page=1 http://www.cnblogs.com/miloyip/archive/2010/06/14 ...

  5. PHP 16: MySql的数据库访问

    原文:PHP 16: MySql的数据库访问 本章介绍PHP访问MySql的方法.如果你对MySQL不是很清晰,可以参看PHP 17: MySQL的简单介绍.对于数据库的操作,无非就是以下几个点: 如 ...

  6. weblogic启动报错--com.octetstring.vde.backend.BackendRoot

    错误现象: 使用bea用户启动weblogic时报错,错误信息如下: <2014-7-29 下午07时47分23秒 CST> <Notice> <Log Manageme ...

  7. leetcode第31题--Longest Valid Parentheses

    Given a string containing just the characters '(' and ')', find the length of the longest valid (wel ...

  8. 《STL源代码剖析》---stl_hash_set.h阅读笔记

    STL仅仅规定接口和复杂度,对于详细实现不作要求.set大多以红黑树实现,但STL在标准规格之外提供了一个所谓的hash_set,以hash table实现.hash_set的接口,hash_tabl ...

  9. C#放缩、截取、合并图片并生成高质量新图的类

    原文:C#放缩.截取.合并图片并生成高质量新图的类 using System;using System.Drawing;using System.Drawing.Imaging;using Syste ...

  10. ibatis提示Unable to load embedded resource from assembly "Entity.Ce_SQL.xml,Entity".

    原本以为是xml文件配置错误,尝试无果,最终原因未将xml文件的生成操作选择为嵌入的资源.很无语!