『公告』 预祝您龙年大吉,万事如意, 过节期间, 大家如需数据服务,请拨打400 或直接添加客服微信,再祝大家龙年,心想事成。
关注我们 新浪 腾讯

AO在线上画注记

AO在线上画注记
当线的起点位于终点的右侧时,线将以相反方向重新绘制,确保文字自动显示在线的上方。

Imports ESRI.ArcGIS.Geometry

Imports ESRI.ArcGIS.Carto

Imports ESRI.ArcGIS.MapControl

Imports ESRI.ArcGIS.Display

 

OnAfterDraw:

 

Dim pTextSymbol As ITextSymbol = New TextSymbol

Dim pFont As stdole.StdFont

pFont = New stdole.StdFont

pFont.Name = "Arial"

pFont.Bold = True

pFont.Size = 16

pTextSymbol.Font = pFont

pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHAFull

 

Dim rgbcolor As IRgbColor = New RgbColor

rgbcolor.RGB = RGB(0, 0, 255)

pTextSymbol.Color = rgbcolor

 

Dim pTextPath As ITextPath

Dim pSimpleTextSymbol As ISimpleTextSymbol

'Create a text path and grab hold of the ITextPath interface

pTextPath = New BezierTextPath 'to spline the text

pSimpleTextSymbol = pTextSymbol 'Grab hold of the ISimpleTextSymbol interface through the ITextSymbol interface

pSimpleTextSymbol.TextPath = pTextPath 'Set the text path of the simple text symbol

'Draw the line object and spline the user text around the line

m_Line = rotatezj(m_Line) '文字位置的自适应调整

AxMapControl1.DrawText(m_Line, "ssfsfsfsfsfsf", pTextSymbol)

 

'当线的起点位于终点的右侧时,线将以相反方向重新绘制,确保文字自动显示在线的上方

Private Function rotatezj(ByVal line As Polyline) As Polyline

Try

Dim ilinetmp As IPolyline

Dim linetmp As Polyline = New Polyline

Dim pt0x, pt0y, pt1x, pt1y As Double

Dim pt0, pt1 As IPoint

 

If line Is Nothing Then Return line : Exit Try

If line.PointCount < 2 Then Return line : Exit Try

 

pt0 = line.Point(0)

pt1 = line.Point(line.PointCount - 1)

AxMapControl1.FromMapPoint(pt0, pt0x, pt0y)

AxMapControl1.FromMapPoint(pt1, pt1x, pt1y)

 

If pt0x < pt1x Then Return line : Exit Function

ilinetmp = linetmp

If pt0x > pt1x Then '需要转换

linetmp = New Polyline

Dim length As Integer = line.PointCount

For i As Integer = length - 1 To 0 Step -1

linetmp.AddPoint(line.Point(i))

Next

End If

Return linetmp

Catch ex As Exception

MsgBox(ex.Message)

End Try

End Function

      京ICP备2025132830号-1 京公网安备 号