阅读:2452回复:4
[原创]arcgis engine下标注图层如何创建
<P>arcgis engine下标注图层如何创建,操作?</P>
<P>那位大虾知道</P> |
|
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> |
|
|
2楼#
发布于:2007-04-11 21:31
[原创]
<P>二楼:</P>
<P> 感谢你的回复,你创建的标注,能不能单独作为一个图层存在? 不依附与其他图层</P> |
|
3楼#
发布于:2007-04-12 09:56
<P>就是单独的图层哈;不过注记层需要保存在sde或者个人数据库里,上面的例子是保存在个人数据库里(*.mdb)</P>
|
|
|
4楼#
发布于:2007-04-12 21:10
<P>楼主:</P>
<P> 我的意思是象mapinfo一样,直接创建标注图层,不需要其他设置</P> |
|