ldj
ldj
路人甲
路人甲
  • 注册日期2003-10-19
  • 发帖数161
  • QQ
  • 铜币737枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:2452回复:4

[原创]arcgis engine下标注图层如何创建

楼主#
更多 发布于:2007-04-09 19:25
<P>arcgis engine下标注图层如何创建,操作?</P>
<P>那位大虾知道</P>
喜欢0 评分0
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2007-04-10 10:19
<H1>IFeatureWorkspaceAnno Example</H1>
<P>The following example show how to use the <STRONG>CreateAnnotationClass </STRONG>on <STRONG>IFeatureWorkspaceAnno </STRONG>to create a new feature-linked annotation class. In this example, the annotation class is feature-linked to the "sew_str" feature class and is created in the same feature dataset as the feature class it is linked to.</P>
<P>The label expression is a simple expression of the values in the field called DESCRIPTION in the sew_str feature class. A text symbol for the feature-linked annotation is red with a font of "Courier New".</P><CODE><PRE>Dim myTxtSym As IFormattedTextSymbol

Private Sub NewAnnoClass()
  ' get a reference to the linked feature class
  Dim pWS As IWorkspace
  Dim pWSF As IWorkspaceFactory
  
  Set pWSF = New AccessWorkspaceFactory
  Set pWS = pWSF.OpenFromFile("D:\data\acsa_new.mdb", 0)
  
  Dim PFWSAnno As IFeatureWorkspaceAnno
  Set PFWSAnno = pWS
    
  Dim pFWS As IFeatureWorkspace
  Set pFWS = pWS
  
  Dim pFDataset As IFeatureDataset
  Set pFDataset = pFWS.OpenFeatureDataset("Sewer")
  
  Dim psrcFClass As IFeatureClass
  Set psrcFClass = pFWS.OpenFeatureClass("sew_str")
  
  ' set up reference scale
  Dim pGLS As IGraphicsLayerScale
  Set pGLS = New GraphicsLayerScale
  
  Dim pGeoDS As IGeoDataset
  Set pGeoDS = pFDataset
  
  pGLS.Units = esriFeet
  pGLS.ReferenceScale = 2000
  
  ' set up symbol collection
  Dim pSymbolColl As ISymbolCollection
  Set pSymbolColl = New SymbolCollection
  
  MakeText
  
  Set pSymbolColl.Symbol(0) = myTxtSym

  ' set up the annotation labeling properties including the expression
  Dim pAnnoProps As IAnnotateLayerProperties
  Set pAnnoProps = New LabelEngineLayerProperties
  
  pAnnoProps.FeatureLinked = True
  pAnnoProps.AddUnplacedToGraphicsContainer = False
  pAnnoProps.CreateUnplacedElements = True
  pAnnoProps.DisplayAnnotation = True
  pAnnoProps.UseOutput = True
  Dim aAnnoVBScriptEngine As IAnnotationExpressionEngine
  Set aAnnoVBScriptEngine = New AnnotationVBScriptEngine
  
  Dim pLELayerProps As ILabelEngineLayerProperties
  Set pLELayerProps = pAnnoProps
  Set pLELayerProps.ExpressionParser = aAnnoVBScriptEngine
  pLELayerProps.Expression = "[DESCRIPTION]"
  
  pLELayerProps.IsExpressionSimple = True
  pLELayerProps.Offset = 0
  pLELayerProps.SymbolID = 0
  Set pLELayerProps.Symbol = myTxtSym
  
  Dim pATP As IAnnotateLayerTransformationProperties
  Set pATP = pAnnoProps
  pATP.ReferenceScale = pGLS.ReferenceScale
  pATP.Units = esriFeet
  pATP.ScaleRatio = 1
  
  Dim pAnnoPropsColl As IAnnotateLayerPropertiesCollection
  Set pAnnoPropsColl = New AnnotateLayerPropertiesCollection
  pAnnoPropsColl.Add pAnnoProps

  ' use the AnnotationFeatureClassDescription co-class to get the list of required fields and the default name of the shape field
  Dim pOCDesc As IObjectClassDescription
  Set pOCDesc = New AnnotationFeatureClassDescription
  Dim pFDesc As IFeatureClassDescription
  Set pFDesc = pOCDesc

  ' create the new class
  Dim pNewClass As IFeatureClass
  Set pNewClass = PFWSAnno.CreateAnnotationClass("AnnoTest", pOCDesc.RequiredFields, pOCDesc.InstanceCLSID, pOCDesc.ClassExtensionCLSID, pFDesc.ShapeFieldName, "", pFDataset, psrcFClass, pAnnoPropsColl, pGLS, pSymbolColl, True)
  
  MsgBox "done"
End Sub

Public Sub MakeText(
  ' helper function to create the text symbol
  Set myTxtSym = New TextSymbol
  '** Set the font for myTxtSym
  Dim myFont As IFontDisp
  Set myFont = New StdFont
  myFont.Name = "Courier New"
  myFont.Size = 9
  myTxtSym.Font = myFont
  '** Set the Color for myTxtSym to be Dark Red
  Dim myColor As IRgbColor
  Set myColor = New RgbColor
  myColor.Red = 150
  myColor.Green = 0
  myColor.Blue = 0
  myTxtSym.Color = myColor
  '** Set other properties for myTxtSym
  myTxtSym.Angle = 0
  myTxtSym.RightToLeft = False
  myTxtSym.VerticalAlignment = esriTVABaseline
  myTxtSym.HorizontalAlignment = esriTHAFull
  myTxtSym.CharacterSpacing = 200
  myTxtSym.Case = esriTCNormal
End Sub</PRE></CODE>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
ldj
ldj
路人甲
路人甲
  • 注册日期2003-10-19
  • 发帖数161
  • QQ
  • 铜币737枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2007-04-11 21:31
[原创]
<P>二楼:</P>
<P>  感谢你的回复,你创建的标注,能不能单独作为一个图层存在? 不依附与其他图层</P>
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
3楼#
发布于:2007-04-12 09:56
<P>就是单独的图层哈;不过注记层需要保存在sde或者个人数据库里,上面的例子是保存在个人数据库里(*.mdb)</P>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
ldj
ldj
路人甲
路人甲
  • 注册日期2003-10-19
  • 发帖数161
  • QQ
  • 铜币737枚
  • 威望0点
  • 贡献值0点
  • 银元0个
4楼#
发布于:2007-04-12 21:10
<P>楼主:</P>
<P>  我的意思是象mapinfo一样,直接创建标注图层,不需要其他设置</P>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部