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 ...
随机推荐
- UiAutomator源码分析之UiAutomatorBridge框架
上一篇文章<UIAutomator源码分析之启动和运行>我们描述了uitautomator从命令行运行到加载测试用例运行测试的整个流程,过程中我们也描述了UiAutomatorBridge ...
- 全球最快的JS模板引擎:tppl
废话不多说,先上测试: 亲测请访问:[在线测试地址]单次结果不一定准确,请多测几次. tppl 的编译渲染速度是著名的 jQuery 作者 John Resig 开发的 tmpl 的 43 倍!与第二 ...
- Erlang常用代码段
十六进制字符串转为二进制 hex_to_bin(Bin) -> hex2bin(Bin). hex2bin(Bin) when is_binary(Bin) -> hex2bin(bina ...
- Android摘要ImageView的scaleType属性
Android在ImageView的scaleType有8一个选项 1 matrix不正确图像放大,原来自view在左上角绘制图片(片不变形): 2 fitXY将图片所有绘制到view中,可是图片会变 ...
- 一个可以直接使用的MsgBox基于form居中API
可直接复制DialogBox项目(文件夹)到需要的项目中然后直接引用和using CodeProject.Dialog 已修正原作者代码错误的地方,可直接使用,VS2010测试成功 具体可以参考案例T ...
- Error with mysqld_safe
出处:http://bugs.mysql.com/bug.php?id=18403 Description: - I downloaded the binary file “Standard 5.0. ...
- weblogic生产、开发模式互转
生产模式与开发模式转换: 1.生产模式-->开发模式 将%DOMAIN_HOME%\config\config.xml文件中<production-mode-enabled> ...
- Smarty属性
Attributes [属性] 大多数函数都带有自己的属性以便于明确说明或者修改他们的行为. smarty函数的属性很像HTML中的属性. 静态数值不需要加引号,但是字符串建议使用引号. 如果用 ...
- c#下载文件案例
public static void HttpDown(string fileName, System.Web.UI.Page p_Page,string floder) { string path ...
- Roslyn 编译平台概述
在Language Feature Status上面看到,其实更新的并不是特别多,为了不会误导看了C# 6.0 功能预览 (一)的园友,现在把官方的更新列表拿了过来,供大家参考 C# 6.0 功能预览 ...