📄 identifypopuptool.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools;
using ESRI.ArcGIS.ADF.Web.UI.WebControls;
using System.Collections;
/// <summary>
/// IdentifyPopUpTool 的摘要说明
/// </summary>
public class IdentifyPopUpTool : IMapServerToolAction
{
public IdentifyPopUpTool()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
#region IMapServerToolAction 成员
public void ServerAction(ESRI.ArcGIS.ADF.Web.UI.WebControls.ToolEventArgs args)
{
ESRI.ArcGIS.ADF.Web.UI.WebControls.Map map = (ESRI.ArcGIS.ADF.Web.UI.WebControls.Map)args.Control;
PointEventArgs pea = (PointEventArgs)args;
System.Drawing.Point peanut = pea.ScreenPoint;
ESRI.ArcGIS.ADF.Web.Geometry.Point point = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(peanut.X, peanut.Y, map.Extent, (int)map.Width.Value, (int)map.Height.Value);
System.Data.DataSet dataset = new System.Data.DataSet();
string sourcelayername = "World Cities";
IEnumerable func_enum = map.GetFunctionalities();
//如果查询结果用TaskResult、GridResullt等窗口显示时,Server会自动产生一个GraphicsLayer,所以需要遍历Functionality,以获取相应IGISFunctionality进行查询
foreach (ESRI.ArcGIS.ADF.Web.DataSources.IGISFunctionality gisfunctionality in func_enum)
{
ESRI.ArcGIS.ADF.Web.DataSources.IGISResource gisresource = gisfunctionality.Resource;
if (gisresource is ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal)
{
bool supportquery = gisresource.SupportsFunctionality(typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality));
if (supportquery)
{
ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality qfunc;
qfunc = (ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality)gisresource.CreateFunctionality(typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), null);
string[] lids;
string[] lnames;
qfunc.GetQueryableLayers(null, out lids, out lnames);
int layer_index = 0;
for (int i = 0; i < lnames.Length; i++)
{
if (lnames[i] == sourcelayername)
{
if (lids[i] is string)
{
if (!int.TryParse((string)lids[i], out layer_index))
layer_index = i;
}
else
{
layer_index = i;
}
break;
}
}
string[] lids1 = new string[1];
lids1[0] = layer_index.ToString();
System.Data.DataTable[] qdatatable = null;
qdatatable = qfunc.Identify(null, point, 3, ESRI.ArcGIS.ADF.Web.IdentifyOption.TopMostLayer, lids1); //查询特定层
if (qdatatable == null)
break;
System.Data.DataTable dtable = qdatatable[0];
string strID = (string)dtable.Rows[0]["CITY_NAME"];
string strName = (string)dtable.Rows[0]["CNTRY_NAME"];
CallbackResult cr2 = new CallbackResult(null, null, "javascript", "showDetail('" + strID + "','" + strName + "','" + peanut.X.ToString() + "','" + peanut.Y.ToString() + "');");
map.CallbackResults.Add(cr2);
}
}
}
object[] oa = new object[1];
string sa = "map.divObject.style.cursor = map.cursor";
oa[0] = sa;
CallbackResult cr1 = new CallbackResult(null, null, "javascript", oa);
map.CallbackResults.Add(cr1);
//throw new Exception("The method or operation is not implemented.");
}
#endregion
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -