目的:
1.MapIdentify功能,自定义Tool以及TaskResults应用
准备:
1.(一、二)的工程,具体见前篇。

开始:
1.编辑Toolbar1的ToolbarItems属性添加一个Tool,ClientAction属性为MapIdentify('Map1'); Name属性为MapIdentify Text属性为Identify ToolTip属性为Identify (Ctrl-MouseClick) 具体代码如下:
1ArcGIS.Server.9.2.DotNet自带例子分析(一、三)<esri:Tool ClientAction="MapIdentify('Map1');" DefaultImage="~/Images/identify.png"
2ArcGIS.Server.9.2.DotNet自带例子分析(一、三)HoverImage="~/Images/identify_HOVER.gif" JavaScriptFile="" Name="MapIdentify" SelectedImage="~/Images/identify_ON.gif" Text="Identify" ToolTip="Identify (Ctrl-MouseClick)" />
2.开始代码部分的编写,添加MapIdentify.cs,用来实现具体的功能。代码和说明如下:
  1ArcGIS.Server.9.2.DotNet自带例子分析(一、三)using System.Web;
  2ArcGIS.Server.9.2.DotNet自带例子分析(一、三)using System.Web.Security;
  3ArcGIS.Server.9.2.DotNet自带例子分析(一、三)using System.Web.UI;
  4ArcGIS.Server.9.2.DotNet自带例子分析(一、三)using System.Web.UI.WebControls;
  5ArcGIS.Server.9.2.DotNet自带例子分析(一、三)using System.Web.UI.WebControls.WebParts;
  6ArcGIS.Server.9.2.DotNet自带例子分析(一、三)using System.Web.UI.HtmlControls;
  7ArcGIS.Server.9.2.DotNet自带例子分析(一、三)using ESRI.ArcGIS.ADF.Web.UI.WebControls;
  8ArcGIS.Server.9.2.DotNet自带例子分析(一、三)using System.Collections.Specialized;
  9ArcGIS.Server.9.2.DotNet自带例子分析(一、三)using ESRI.ArcGIS.ADF.Web.DataSources;
 10ArcGIS.Server.9.2.DotNet自带例子分析(一、三)using System.Collections.Generic;
 11ArcGIS.Server.9.2.DotNet自带例子分析(一、三)using ESRI.ArcGIS.ADF.Web;
 12ArcGIS.Server.9.2.DotNet自带例子分析(一、三)using ESRI.ArcGIS.ADF.Web.Display.Graphics;
 13ArcGIS.Server.9.2.DotNet自带例子分析(一、三)
 14ArcGIS.Server.9.2.DotNet自带例子分析(一、三)namespace MappingApp
 15
3.在页面上新增TaskResults控件用来显示查询内容ID为TaskResults1,接着在Page_Load事件里添加实例化上面的MapIdentify类具体代码和说明如下:
1ArcGIS.Server.9.2.DotNet自带例子分析(一、三)//实例化MapIdentify,并且把Map1控件作为参数
2ArcGIS.Server.9.2.DotNet自带例子分析(一、三)MapIdentify identify = new MapIdentify(Map1);
3ArcGIS.Server.9.2.DotNet自带例子分析(一、三)//显示查询结果的控件
4ArcGIS.Server.9.2.DotNet自带例子分析(一、三)identify.ResultsDisplay = TaskResults1;
5ArcGIS.Server.9.2.DotNet自带例子分析(一、三)//小数位数
6ArcGIS.Server.9.2.DotNet自带例子分析(一、三)identify.NumberDecimals = 4;
4.接着还需要对RaiseCallbackEvent方法进行修改添加对查询结果处理的代码,具体代码和说明如下:
 1ArcGIS.Server.9.2.DotNet自带例子分析(一、三)//对客户端的请求进行处理
 2ArcGIS.Server.9.2.DotNet自带例子分析(一、三)        public virtual string RaiseCallbackEvent(string responseString)
 3        }
5.还需要编写客户端的脚本MapIdentify('Map1');响应MapIdentify工具的操作,在javascript目录中新增display_mapidentify.js文件,至于页面对这个文件的引用在前面的MapIdentify类的SetupIdentify()方法已经添加的对这个文件的引用,具体的代码和说明如下:
 1ArcGIS.Server.9.2.DotNet自带例子分析(一、三)//路径
 2ArcGIS.Server.9.2.DotNet自带例子分析(一、三)var identifyFilePath = "";
 3ArcGIS.Server.9.2.DotNet自带例子分析(一、三)var identifyImageType = "png";
 4ArcGIS.Server.9.2.DotNet自带例子分析(一、三)
 5ArcGIS.Server.9.2.DotNet自带例子分析(一、三)//Tool MapIdentify的ClientAction
 6ArcGIS.Server.9.2.DotNet自带例子分析(一、三)function MapIdentify(divid) 
 7}
6.到此为止完成了Identify功能的开发,调试运行查看效果。剩下的下一篇继续写。
ArcGIS.Server.9.2.DotNet自带例子分析(一、三)

相关文章: