定义查询(根据字段内容显示要素)

yongxinz

关注

阅读 31

2022-03-30

  public static void ShowFeaturesByFieldValue(this IFeatureLayer pFeatureLayer, string filedName, string value)
        {
            if (pFeatureLayer == null)
            {
                return;
            }
            ESRI.ArcGIS.Carto.IFeatureLayerDefinition pDef = (ESRI.ArcGIS.Carto.IFeatureLayerDefinition)pFeatureLayer;
            IActiveView activeView = ArcMap.Document.FocusMap as IActiveView;
            string mWhere = string.Empty;
            if (value.Length == 0)
            {
                mWhere = "";
            }
            else
            {
                mWhere = filedName + "='" + value + "'";
            }
            //清除现有选择
            pDef.DefinitionExpression = "";
            activeView.Refresh();
            pDef.DefinitionExpression = mWhere;
            activeView.Refresh();
        }


        public static void ShowFeaturesByFieldValue(IMap map, IFeatureLayer pFeatureLayer, string filedName, string value)
        {
            ESRI.ArcGIS.Carto.IFeatureLayerDefinition pDef = (ESRI.ArcGIS.Carto.IFeatureLayerDefinition)pFeatureLayer;
            IActiveView activeView = map as IActiveView;
            string mWhere = string.Empty;
            if (value.Length == 0)
            {
                mWhere = "";
            }
            else
            {
                mWhere = filedName + "='" + value + "'";
            }
            //清除现有选择
            pDef.DefinitionExpression = "";
            activeView.Refresh();
            pDef.DefinitionExpression = mWhere;
            activeView.Refresh();
        }

精彩评论(0)

0 0 举报