首页 文章

ArcGis Engine,如何突出一些功能/形状?

提问于
浏览
1

在使用ArcGis Engine的独立c#/ wpf应用程序中,我加载了一些形状,selected some features .

现在我想强调一个选定的功能 . 我可以在IFeatureSelection / Layer上找到对象/特征,我从IFeature.Shape获得了IGeometry .

是否有一种简单的方法来标记已知的特征/形状,例如红色或类似的东西?

我有这样的功能使用这样的东西:

AxMapControl _mapControl;
IFeatureSelection features = _mapControl.Map.Layer[0] as IFeatureSelection;
ICursor cursor;
features.SelectionSet.Search(null, true, out cursor);
IFeature feature;
while ((feature = ((IFeatureCursor)cursor).NextFeature()) != null)
{
  IGeometry geometry = feature.Shape;
}

我搜查了样本,但无法找到我需要的东西 .

1 回答

  • 0
    static public void FlashFeature(IFeature feature)
            {
                if (feature == null)
                    return;
                IApplication app = ApplicationRef;
                IMxDocument doc = (IMxDocument)(app.Document);
    
                IFeatureIdentifyObj feature_identify_obj = new FeatureIdentifyObjectClass();
                feature_identify_obj.Feature = feature;
                ((IIdentifyObj)feature_identify_obj).Flash(doc.ActiveView.ScreenDisplay);
            }
    

    ApplicationRef的位置是:

    static public IApplication ApplicationRef
            {
                get
                {
                    Type obj_type = Type.GetTypeFromCLSID(typeof(AppRefClass).GUID);
    
                    IApplication obj = null;
                    try
                    {
                        obj = (IApplication)Activator.CreateInstance(obj_type);
                    }
                    catch {}
    
                    return obj;
                }
            }
    

    或者你可以通过在IGraphicsContainer中创建图形IElement元素来实现,如:

    void ShowFeature(IFeature feature)
            {
                element.Geometry = geometry.Project(mapSpatialReference, feature.Shape);
    
                graphicsContainer.AddElement(element, 0);
    
                activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
    
                featureHighlighted = true;
            }
    
            void HideFeature()
            {
                if (!featureHighlighted)
                    return;
    
                graphicsContainer.DeleteElement(element);
    
                activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
    
                featureHighlighted = false;
            }
    

相关问题