zoukankan      html  css  js  c++  java
  • ArcGIS Server点击查询

    ArcGIS Server点击查询

    (1)创建新类,类名为 IdentifyPopTool ,并实现IMapServerToolAction接口

    public class IdentifyPopUpTool : IMapServerToolAction
        {
            #region IMapServerToolAction Members
            void IMapServerToolAction.ServerAction(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 = "City";
                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]["XMBH"];
                            string strName = (string)dtable.Rows[0]["XMMC"];
                            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);
            }
            #endregion
        }

    (2)设置查询GIS工具按钮


    <esri:Tool DefaultImage="~/Images/identify.png" JavaScriptFile="" ServerActionAssembly="App_Code" HoverImage="~/Images/identify_HOVER.gif" ServerActionClass="CustomToolLibrary.IdentifyPopUpTool" ClientAction="Point" ToolTip="点击查询要素" SelectedImage="~/Images/identify_ON.gif" Name="点击查询"></esri:Tool>

     

  • 相关阅读:
    HDOJ 4248 A Famous Stone Collector DP
    Android开发系列(十九个):至SimpleAdapter设置样式
    matlab入门 蜂窝阵列
    OpenGL缓冲区
    如何在终端编辑命令
    struts2跳转类型解析
    设计模式(Facade)状态(注意事项)
    Swift与Objective-C API的交互
    Swift调用Objective C的FrameWork
    初探swift语言的学习—Object-C与Swift混编
  • 原文地址:https://www.cnblogs.com/gisbase/p/1627420.html
Copyright © 2011-2022 走看看