English

How To: Work with DrawTextPolyline on a MapDisplay

Procedure

Question:

How do I use the DrawTextPolyline request on a MapDisplay? [SCRIPT]

Answer:

A MapDisplay uses coordinate values. It can be a screen area, such as a View, that uses real world coordinates.

The DrawTextPolyline request draws a string around a polyline object.

The following sample code shows how to use the DrawTextPolyline request on a MapDisplay:

'****** Sample Script ******
'
'Gets a theme's polyline assuming that there
'is a View called "View1" and a single
'theme with only one selected polyline feature.
'
aView=av.GetProject.FindDoc("View1")
aFtab=aView.GetThemes.Get(0).GetFtab
aFld=aFtab.FindField("Shape")
theBitmap = aFtab.GetSelection

'Get the polyline from the Ftab and the
'msgbox should return back the polyline
'
If (theBitmap.Count <> 1) then
MsgBox.Warning("Sample Code is only for 1 selected feature","Stop")
return nil
else

for each b in theBitmap

aPline=aFtab.ReturnValue(aFld, b)
msgbox.report(aPline.AsString,"")

'Create a string object to be drawn
'
aStr="This is a test"

'Create a Font and Textsymbol to be used later
'
aFont=Font.MakeStandard(#FONT_COURB)
msgbox.info(aFont.GetStyle,"aFontStyle")

aTs=TextSymbol.Make
aTs.SetFont(aFont)
aTs.SetSize(14)
aTs.SetColor(Color.GetRed)

'Get the View's Display and draw the string
'on the display
'
ld=aView.getDisplay
ld.BeginClip
ld.Drawtextpolyline(aPline, aStr, aTs)
ld.EndClip

end 'if statement
end 'for each
'****** End of Script ******