ArcIMS 9.2 ADFZoomtoQueryFeature

    protected void Button1_Click(object sender, EventArgs e)

    {

        IEnumerator egrc = MapResourceManager1.GetResources().GetEnumerator();

       

        // If no Map is available, initialize the MapResourceManager

        MapResourceManager1.Initialize();

 

        while (egrc.MoveNext())

        {

            IGISResource gisresource = (IGISResource)egrc.Current;

 

            // If no Map is available, initialize the GISResource

            gisresource.Initialize();

 

            bool supportquery = gisresource.SupportsFunctionality(typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality));

 

            Random random = new Random();

            int randout = random.Next(0, 1000);

 

            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);

 

                string sourcelayername = "states";

 

                int layer_index = 0;

                for (int i = 0; i < lnames.Length; i++)

                {

                    if (lnames[i] == sourcelayername)

                    {

                        layer_index = i;

                        break;

                    }

                }

 

                ESRI.ArcGIS.ADF.Web.QueryFilter queryfilter = new ESRI.ArcGIS.ADF.Web.QueryFilter();

                string fieldlist = "ZD_DJH";

                ESRI.ArcGIS.ADF.StringCollection strcollection = new ESRI.ArcGIS.ADF.StringCollection(fieldlist, ',');

                queryfilter.SubFields = strcollection;

                queryfilter.ReturnADFGeometries = true;

 

                //queryfilter.WhereClause = "ZD_DJH LIKE '210205001019%'";

                queryfilter.WhereClause = "ZD_DJH = '210205001004003'";

 

                System.Data.DataTable qdatatable = qfunc.Query(null, lids[layer_index], queryfilter);

                qdatatable.Columns[0].ColumnName = "STATE_NAME_ALIAS";

                Session["dt" + randout] = qdatatable;

 

                ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicsLayer graphicslayer=

                    ESRI.ArcGIS.ADF.Web.UI.WebControls.Converter.ToGraphicsLayer(qdatatable);

                int count = graphicslayer.Rows.Count;

                Map1.Extent = graphicslayer.FullExtent;        

 

            }

            //To assign each window a random number - to open multiple windows from the same parent

            string argval = "?id=" + randout;

            Response.Write("<script>window.open('TableDialog.aspx" + argval +"', '" + randout.ToString() + "', 'dependent=yes ,width=400, height=200, status=no, toolbar=no, menubar=no, location=no, resizable=yes, scrollbars=yes'); </script>");

 

            //More info: http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/showmodelessdialog.asp

            //Response.Write("<script>window.showModelessDialog('TableDialog.aspx" + argval + "'); </script>");

        }

    }

原文地址:https://www.cnblogs.com/yansc/p/812966.html