Innovate the future

Find the passion of life...
  首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

ArcGIS Server开发——标注

Posted on 2005-05-11 09:28  BPM  阅读(4268)  评论(23编辑  收藏  举报

[VB.NET写法]
Private Sub LabelFeature(ByVal pFeaturelayer As IFeatureLayer, ByVal pServerContext As IServerContext)
   Dim pGeoFeatureLayer As IGeoFeatureLayer
   pGeoFeatureLayer = pFeaturelayer
   pGeoFeatureLayer .AnnotationProperties.Clear()
   Dim pAnnoLayerProColl As IAnnotateLayerPropertiesCollection
   Dim pLabelEngine As ILabelEngineLayerProperties
   pAnnoLayerProColl = pGeoFeatureLayer .AnnotationProperties
   Dim pAnnoLayerProps As IAnnotateLayerProperties
   pLabelEngine = pServerContext.CreateObject("esriCarto.LabelEngineLayerProperties") 
   pLabelEngine .Expression = "[Filed]"
   pAnnoLayerProps = pLabelEngine 
   'pAnnoLayerProps.LabelWhichFeatures = esriSelectedFeatures '转换Graphic时可以利用 
   pAnnoLayerProColl .Add(pAnnoLayerProps)
   pGeoFeatureLayer.DisplayAnnotation = True
End Sub     

[C#写法]
private void LabelField(IFeatureLayer pFeatureLayer,IServerContext pServerContext)
  { 
   IGeoFeatureLayer pGeoFeatureLayer = pFeatureLayer as IGeoFeatureLayer;
   pGeoFeatureLayer.AnnotationProperties.Clear();
   IAnnotateLayerPropertiesCollection pAnnoLayerPropsColl = pGeoFeatureLayer.AnnotationProperties;
   ILabelEngineLayerProperties pLabelEngine;
   
   pLabelEngine = pServerContext.CreateObject("esriCarto.LabelEngineLayerProperties") as     ILabelEngineLayerProperties;
   pLabelEngine.Expression = "[Field]";
   IAnnotateLayerProperties pAnnoLayerProps = pLabelEngine as IAnnotateLayerProperties;
   pAnnoLayerPropsColl.Add(pAnnoLayerProps);
   pGeoFeatureLayer.DisplayAnnotation = true; 
  }