当前位置: 首页>>代码示例>>C#>>正文


C# IMap.SelectFeature方法代码示例

本文整理汇总了C#中IMap.SelectFeature方法的典型用法代码示例。如果您正苦于以下问题:C# IMap.SelectFeature方法的具体用法?C# IMap.SelectFeature怎么用?C# IMap.SelectFeature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMap的用法示例。


在下文中一共展示了IMap.SelectFeature方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SelectFeaturesOnMap

        /// <summary>
        /// Selects a feature on the map.
        /// </summary>
        /// <param name="feature">The feature to select.</param>
        /// <param name="map">The map.</param>
        /// <returns>Returns true if the feature was selected, otherwise returns false.</returns>
        public static bool SelectFeaturesOnMap(IList<IFeature> features, IMap map)
        {
            bool selectionSuccessful = false;

            if (features != null && map != null)
            {
                IActiveView activeView = map as IActiveView;

                if (activeView != null)
                {
                    try
                    {
                        activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                        map.ClearSelection();

                        foreach (IFeature feature in features)
                        {
                            string qualifiedName = DisplayMap.GetQualifiedName(feature);
                            ILayer layer = GetLayerForFeature(feature, map);
                            if (layer != null)
                                map.SelectFeature(layer, feature);
                        }

                        activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                        InvalidateMap(features, (IActiveView)map);
                        selectionSuccessful = true;
                    }
                    catch (Exception e)
                    {
                        //_logger.LogAndDisplayException(e);
                    }
                }
            }
            return selectionSuccessful;
        }
开发者ID:Ramakrishnapv,项目名称:FuturaNetwork,代码行数:41,代码来源:DisplayMap.cs

示例2: SelectFeatureOnMap

        /// <summary>
        /// Selects a feature on the map.
        /// </summary>
        /// <param name="feature">The feature to select.</param>
        /// <param name="map">The map.</param>
        /// <returns>Returns true if the feature was selected, otherwise returns false.</returns>
        public static bool SelectFeatureOnMap(IFeature feature, IMap map)
        {
            bool selectionSuccessful = false;
            if (feature != null && map != null)
            {
                try
                {
                    //string qualifiedName = DataContainer.GetQualifiedName(feature);
                    ILayer layer = GetLayerForFeature(feature, map);

                    PartialRefresh((IActiveView)map);
                    map.ClearSelection();
                    if (layer != null)
                    {
                        map.SelectFeature(layer, feature);
                        PartialRefresh((IActiveView)map);
                        InvalidateMap(feature, (IActiveView)map);
                        selectionSuccessful = true;
                    }
                }
                catch (Exception e)
                {
                    //_logger.LogAndDisplayException(e);
                }
            }
            return selectionSuccessful;
        }
开发者ID:Ramakrishnapv,项目名称:FuturaNetwork,代码行数:33,代码来源:DisplayMap.cs

示例3: SelectFeature

        /// <summary>
        /// Selects a feature on the map.
        /// </summary>
        /// <param name="feature">The feature to select.</param>
        /// <param name="map">The map.</param>
        /// <returns>Returns true if the feature was selected, otherwise returns false.</returns>
        public static bool SelectFeature(IFeature feature, IMap map, IActiveView activeView, bool isInternalSelection)
        {
            bool selectionSuccessful = false;

            if (feature != null && map != null)
            {
                try
                {
                    // Core.DeveloperSettings.IsInternalSelection = true;
                    ILayer layer = GetLayerForFeature(feature, map);
                    map.ClearSelection();

                    if (layer != null)
                    {
                        map.SelectFeature(layer, feature);

                        if (activeView != null)
                            activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, activeView.Extent);

                        InvalidateMap(feature, activeView);
                        selectionSuccessful = true;
                    }
                }
                catch (Exception e)
                {
                    //_logger.LogAndDisplayException(e);
                }
                finally
                {
                    // Core.DeveloperSettings.IsInternalSelection = false;
                }
            }
            return selectionSuccessful;
        }
开发者ID:Ramakrishnapv,项目名称:FuturaNetwork,代码行数:40,代码来源:DisplayMap.cs

示例4: AddFeatureToSelection

 /// <summary>
 /// Adds a feature to the map selection.
 /// </summary>
 /// <param name="feature">The feature to add to the selection.</param>
 /// <param name="layer">The layer to which the feature belongs.</param>
 /// <param name="map">The map.</param>
 public static void AddFeatureToSelection(IFeature feature, ILayer layer, IMap map)
 {
     if (feature != null && layer != null && map != null)
         map.SelectFeature(layer, feature);
 }
开发者ID:Ramakrishnapv,项目名称:FuturaNetwork,代码行数:11,代码来源:DisplayMap.cs

示例5: ClickSelectFeature

        private void ClickSelectFeature(ref IMap m_pMap, int x, int y)
        {
            // get the layer
            IFeatureLayer pFeatureLayer = m_pMap.get_Layer(0) as IFeatureLayer;
            if (pFeatureLayer == null) return;
            IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;//get the feature
            if (pFeatureClass == null) return;
            //get mouse position
            IActiveView pActiveView = m_pMap as IActiveView;
            IPoint pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
            //Use a 4 pixel buffer around the cursor for feature search
            double length;
            length = ConvertPixelsToMapUnits(pActiveView, 4);
            ITopologicalOperator pTopo = pPoint as ITopologicalOperator;
            IGeometry pBuffer = pTopo.Buffer(length);//建立4个地图单位的缓冲区
            IGeometry pGeometry = pBuffer.Envelope;//确定鼠标周围隐藏的选择框

            //新建一个空间约束器
            ISpatialFilter pSpatialFilter;
            IQueryFilter pFilter;
            //设置查询约束条件
            pSpatialFilter = new SpatialFilter();
            pSpatialFilter.Geometry = pGeometry;

            switch (pFeatureClass.ShapeType)
            {
                case esriGeometryType.esriGeometryPoint:
                    pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;
                    break;
                case esriGeometryType.esriGeometryPolyline:
                    pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelCrosses;
                    break;
                case esriGeometryType.esriGeometryPolygon:
                    pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                    break;
                default:
                    break;
            }
            pSpatialFilter.GeometryField = pFeatureClass.ShapeFieldName;
            pFilter = pSpatialFilter;
            //Do the Search 从图层中查询出满足约束条件的元素
            IFeatureCursor pCursor = pFeatureLayer.Search(pFilter, false);

            //select
            IFeature pFeature = pCursor.NextFeature();
            m_pMap.SelectFeature(pFeatureLayer, pFeature);
            while (pFeature != null)
            {
                m_pMap.SelectFeature(pFeatureLayer, pFeature);
                pFeature = pCursor.NextFeature();
            }

            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
        }
开发者ID:gistop,项目名称:aegis,代码行数:54,代码来源:Home.cs

示例6: SearchHightlight

        void SearchHightlight(IMap _pMap,IFeatureLayer _pFeatureLayer, IQueryFilter _pQuery, bool _Bool)
        {
            IFeatureCursor pFtCursor = _pFeatureLayer.Search(_pQuery, _Bool);

            IFeature pFt = pFtCursor.NextFeature();

            while (pFt != null)
            {
                _pMap.SelectFeature(_pFeatureLayer as ILayer, pFt);

                pFt = pFtCursor.NextFeature();

            }
        }
开发者ID:esrichina,项目名称:Engine10DevApplication,代码行数:14,代码来源:MainForm.cs


注:本文中的IMap.SelectFeature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。