Arc Engine 高亮要素

通过光标位置找到所在的要素,进行高亮显示。

                IPoint pPoint = new PointClass();

                pPoint.PutCoords(e.mapX, e.mapY);

                ITopologicalOperator pTopo = pPoint as ITopologicalOperator;

                double m_Radius = e.mapX / 100000000000;

                IGeometry pGeometry = pTopo.Buffer(m_Radius);

                //if (pGeometry == null)

                //    continue;

                axMapControl1.Map.SelectByShape(pGeometry, null, true);//第三个参数为是否只选中一个

                axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null); //选中要素高亮显示

                ISpatialFilter pFilter = new SpatialFilterClass();

                pFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;

                pFilter.Geometry = pGeometry;

                IFeatureLayer pFeatureLayer = new FeatureLayerClass();

                for (int i = 0; i < axMapControl1.LayerCount; i++)

                {

                    ILayer ptempLayer = axMapControl1.get_Layer(i);

                    if (ptempLayer.Name == "样本矢量")

                        pFeatureLayer = ptempLayer as IFeatureLayer;

                }

                IFeatureSelection pSelection = pFeatureLayer as IFeatureSelection;

                pSelection.SelectFeatures((IQueryFilter)pFilter, esriSelectionResultEnum.esriSelectionResultAdd, false);

                ISimpleFillSymbol pSym = new SimpleFillSymbolClass();

                IRgbColor pRGBColor = new RgbColorClass();

                pRGBColor.NullColor = true;

                pSym.Color = pRGBColor as IColor;

                ILineSymbol pLineSymbol = new SimpleLineSymbolClass();

                IRgbColor pRgbColor = new RgbColorClass();

                pRgbColor.Red = 0;

                pRgbColor.Green = 0;

                pRgbColor.Blue = 255;

                pRgbColor.Transparency = 5;

                pLineSymbol.Color = pRgbColor as IColor;

                pLineSymbol.Width = 2;

                //pLineFillSymbol.LineSymbol = pLineSymbol;

                pSym.Outline = pLineSymbol;

                pSelection.SetSelectionSymbol = true;

                pSelection.SelectionSymbol = (ISymbol)pSym;

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容