阅读:1878回复:3
如何产生一注记层,并由xy 坐标产生一文本注记
如何产生一注记层,并由xy 坐标产生一文本注记?
|
|
1楼#
发布于:2004-08-02 08:30
新建注记层我倒没做过,用x,y做标注倒是木有问题滴说,可以看看帮助了
|
|
|
2楼#
发布于:2004-08-06 11:28
<P><b>注记层可以通过ArcCatalog去建,但是注意,注记层只能在GeoDataBase中存在。</b></P><P><b>向上加要素,你可去差一下帮助中的IFDOGraphicsLayer这个接口。我可以给你提供一下程序。</b></P><P>
'******************************** '** ** '** 添加标注 ** '** ** '******************************** Public Sub AddAnnotation(ByVal x As Double, y As Double, pFeatureLayer As IFeatureLayer) Dim str As String Dim pElement As IElement Dim pTextElement As ITextElement Dim pFillColor As IRgbColor, pLineColor As IRgbColor Dim pFillSymbol As IFillSymbol Dim pLineSymbol As ILineSymbol Dim pBalloonCallout As IBalloonCallout Dim pFormattedTextSymbol As IFormattedTextSymbol Dim pPoint As IPoint, pTextPoint As IPoint Dim pFeatureClass As IFeatureClass Dim pFeature As IFeature Dim pFDOGraphicsLayer As IFDOGraphicsLayer str = Trim(InputBox("请输入注记名称:", "添加注记")) '判断输入的主机是否为空 If str = "" Then MsgBox "注记不许为空!", vbApplicationModal + vbOKOnly, "警告" Exit Sub End If Set pPoint = New Point pPoint.PutCoords x, y '****************************************************************************** '对textSymbol的BackGround进行设置 ** '** Set pFillColor = New RgbColor '** With pFillColor '** .Red = 28 '** .Green = 233 '** .Blue = 78 '** End With '** '** Set pLineColor = New RgbColor '** With pLineColor '** .Red = 0 '** .Green = 0 '** .Blue = 0 '** End With '** Set pLineSymbol = New SimpleLineSymbol '** pLineSymbol.Color = pLineColor '** pLineSymbol.Width = 1 '** '** Set pFillSymbol = New SimpleFillSymbol '** pFillSymbol.Color = pFillColor '** pFillSymbol.Outline = pLineSymbol '** '** Set pBalloonCallout = New BalloonCallout '** pBalloonCallout.Style = esriBCSRoundedRectangle '** pBalloonCallout.AnchorPoint = pPoint '** Set pBalloonCallout.Symbol = pFillSymbol '** '** '****************************************************************************** '对textSymbol的设置 Set pFormattedTextSymbol = New TextSymbol Set pFormattedTextSymbol.Background = pBalloonCallout pFormattedTextSymbol.Font.Name = "宋体" pFormattedTextSymbol.Size = 10 pFormattedTextSymbol.HorizontalAlignment = esriTHACenter pFormattedTextSymbol.TypeSetting = True Set pTextElement = New TextElement pTextElement.Text = str pTextElement.ScaleText = True pTextElement.Symbol = pFormattedTextSymbol Set pTextPoint = New Point pTextPoint.PutCoords x + 0.0005, y + 0.0002 Set pElement = pTextElement pElement.Geometry = pTextPoint '进行创建新的要素 Set pFeatureClass = pFeatureLayer.FeatureClass Set pFeature = pFeatureClass.CreateFeature Set pFDOGraphicsLayer = New FDOGraphicsLayer Set pFDOGraphicsLayer = pFeatureLayer</P><P> pFDOGraphicsLayer.BeginAddElements pFDOGraphicsLayer.DoAddFeature pFeature, pElement, 0 pFDOGraphicsLayer.EndAddElements Frm_main.MapControl1.ActiveView.PartialRefresh esriViewGraphics, Nothing, Nothing Set pPoint = Nothing Set pTextPoint = Nothing Set pTextElement = Nothing Set pFormattedTextSymbol = Nothing Set pFDOGraphicsLayer = Nothing Set pFillColor = Nothing Set pLineColor = Nothing Set pBalloonCallout = Nothing Set pLineSymbol = Nothing Set pFillSymbol = Nothing End Sub</P> |
|
3楼#
发布于:2005-11-28 14:36
多谢学习<img src="images/post/smile/dvbbs/em02.gif" />
|
|
|