2011-03-22 124 views
1

在使用ArcGis Engine的獨立c#/ wpf應用程序中,我加載了一些形狀,selected some featuresArcGis Engine如何突出顯示某些功能/形狀?

現在我想突出顯示所選功能之一。我可以在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

您也可以嘗試:http://gis.stackexchange.com/ – mlsteeves 2011-03-22 14:47:49

回答

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; 
     } 
+0

首先如此lution不起作用,當爲ApplicationRef調用Activator.CreateInstance時,我得到一個COM異常:80040154類未註冊(HRESULT:0x80040154(REGDB_E_CLASSNOTREG))。 – Sam 2011-03-29 09:02:03

相關問題