Beispiel #1
0
        public void TestAsg()
        {
            IServerContext svrContxt = null;

            try
            {
                svrContxt = ServerUtility.GetServerContext(this.Page);
                //3.创建serverObjects
                IPoint pt = svrContxt.CreateObject(PublicConst.Lbl_GeoObjt_Point) as IPoint;
                pt.X             = 100;
                pt.Y             = 200;
                sCallBackFuncStr = JsMesage.ShowMessage(Map1, string.Format("x={0},y={1}", pt.X, pt.Y));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                System.Diagnostics.Debug.WriteLine(ex);
            }
            finally
            {
                if (svrContxt != null)
                {
                    svrContxt.ReleaseContext(); svrContxt = null;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// 根据属性定位
        /// </summary>
        private void LocalByAttribute(string eventArgs)
        {
            if (string.IsNullOrEmpty(eventArgs))
            {
                return;
            }

            try
            {
                IEnumerable func_enum = null;
                DataTable   table     = null;
                //获取当前map的所有functionlity  图层名BOUNT_poly
                func_enum = Map1.GetFunctionalities();
                //d对所有的functionlity遍历
                foreach (IGISFunctionality gisFunclity in func_enum)
                {
                    IGISResource        gisResr = null;
                    IQueryFunctionality qFunc;
                    gisResr = gisFunclity.Resource;
                    if (gisResr == null)
                    {
                        continue;
                    }
                    //判断是否支持IQueryFunctionality
                    bool isSurport = false;
                    isSurport = gisResr.SupportsFunctionality(typeof(IQueryFunctionality));
                    if (!isSurport)
                    {
                        continue;
                    }
                    qFunc = gisResr.CreateFunctionality(typeof(IQueryFunctionality), null) as IQueryFunctionality;
                    if (qFunc == null)
                    {
                        continue;
                    }
                    //获取图层layerid和layerName
                    string[] layerIds, layerNames;
                    qFunc.GetQueryableLayers(null, out layerIds, out layerNames);
                    if (layerIds == null || layerIds.Length == 0)
                    {
                        continue;
                    }
                    int layerId = -1;
                    for (int i = 0; i < layerIds.Length; i++)
                    {
                        if (layerNames[i] == "res2_4m")
                        {
                            layerId = i;
                            break;
                        }
                    }
                    if (layerId == -1)
                    {
                        continue;
                    }
                    //设置过滤器的过滤条件
                    ESRI.ArcGIS.ADF.Web.SpatialFilter sf = new ESRI.ArcGIS.ADF.Web.SpatialFilter();
                    sf.ReturnADFGeometries = true;
                    sf.MaxRecords          = 100;

                    string name = CallbackUtility.ParseStringIntoNameValueCollection(eventArgs)["attr"];
                    sf.WhereClause = string.Format("NAME='{0}'", name);
                    //对指定图层进行查询,查询结果保存为
                    table = qFunc.Query(null, layerIds[layerId], sf);
                    if (table == null || table.Rows.Count == 0)
                    {
                        sCallBackFuncStr = JsMesage.ShowMessage(Map1, "没有找到该城市");
                        continue;
                    }
                    for (int i = 0; i < table.Columns.Count; i++)
                    {
                        DataColumn column = table.Columns[i];
                        if (column.DataType == typeof(Geometry))
                        {
                            ESRI.ArcGIS.ADF.Web.Geometry.Point adfPt = table.Rows[0][i] as ESRI.ArcGIS.ADF.Web.Geometry.Point;
                            try
                            {
                                Map1.CenterAt(adfPt);
                            }
                            catch (Exception ex)
                            {
                                System.Diagnostics.Debug.WriteLine(ex);
                            }
                            try
                            {
                                DrawBufferByPoint(adfPt);
                            }
                            catch (Exception ex)
                            {
                                System.Diagnostics.Debug.WriteLine(ex);
                            }
                            sCallBackFuncStr = Map1.CallbackResults.ToString();
                            return;
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }