|
Private Sub SuperMap1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
'在鼠标点击处加入一个文本到TrackingLayer上,其中:文本的内容和大小在程序中写定,也可以修改。
If SuperMap1.Action = 100000 Then
Dim objGeoPoint As New soGeoPoint
Dim objStyle As New soStyle
SuperMap1.TrackingLayer.ClearEvents
'设置文本定位点的颜色、大小和符号类别
objStyle.PenColor = vbRed
objStyle.SymbolSize = 30
objStyle.SymbolStyle = 1
'设置此点的坐标
objGeoPoint.x = SuperMap1.PixelToMapX(ScaleX(x, vbTwips, vbPixels))
objGeoPoint.y = SuperMap1.PixelToMapY(ScaleY(y, vbTwips, vbPixels))
'加入点到TrackingLayer上
SuperMap1.TrackingLayer.AddEvent objGeoPoint, objStyle, ""
Dim objGeoText As New soGeoText
Dim objTextPart As New soTextPart
'设置文本的内容,可以修改
objTextPart.Text = "SuperMap"
'设置文本的定位点
objTextPart.x = objGeoPoint.x
objTextPart.y = objGeoPoint.y
'设置文本的旋转角度
objTextPart.Rotation = 0
'把文本子对象加入到文本对象中
objGeoText.AddPart objTextPart
Dim objGeoTextStyle As New soTextStyle '文本风格对象
With objGeoTextStyle
.Color = vbBlue
.FontHeight = 4000000
.Align = sctBottomCenter
End With
Set objGeoText.TextStyle = objGeoTextStyle '设置文本的风格
'加入文本到TrackingLayer上
SuperMap1.TrackingLayer.AddEvent objGeoText, Nothing, ""
SuperMap1.TrackingLayer.Refresh
End If
'释放对象变量
Set objGeoTextStyle = Nothing
Set objTextPart = Nothing
Set objGeoText = Nothing
Set objGeoPoint = Nothing
Set objStyle = Nothing
End Sub |