Option Explicit
Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
'Point buffering
If Option1.Value Then
Dim pt As New MapObjects2.Point
Dim eventPt As New MapObjects2.GeoEvent
Dim buffPt As New MapObjects2.Polygon
Dim buffEventPt As New MapObjects2.GeoEvent
Set pt = Map1.ToMapPoint(x, y)
Set eventPt = Map1.TrackingLayer.AddEvent(pt, 0)
Set buffPt = pt.Buffer(Text1.Text, Map1.FullExtent)
Set buffEventPt = Map1.TrackingLayer.AddEvent(buffPt, 3)
'Line buffering
ElseIf Option2.Value Then
Dim line As New MapObjects2.line
Dim eventLine As New MapObjects2.GeoEvent
Dim buffLine As New MapObjects2.Polygon
Dim buffEventLine As New MapObjects2.GeoEvent
Set line = Map1.TrackLine
Set eventLine = Map1.TrackingLayer.AddEvent(line, 1)
Set buffLine = line.Buffer(Text1.Text, Map1.FullExtent)
Set buffEventLine = Map1.TrackingLayer.AddEvent(buffLine, 3)
'Rectangle buffering
ElseIf Option3.Value Then
Dim rect As New MapObjects2.Rectangle
Dim eventRect As New MapObjects2.GeoEvent
Dim buffRect As New MapObjects2.Polygon
Dim buffEventRect As New MapObjects2.GeoEvent
Set rect = Map1.TrackRectangle
Set eventRect = Map1.TrackingLayer.AddEvent(rect, 2)
Set buffRect = rect.Buffer(Text1.Text, Map1.FullExtent)
Set buffEventRect = Map1.TrackingLayer.AddEvent(buffRect, 3)
'Polygon buffering
ElseIf Option4.Value Then
Dim poly As New MapObjects2.Polygon
Dim eventPoly As New MapObjects2.GeoEvent
Dim buffPoly As New MapObjects2.Polygon
Dim buffEventPoly As New MapObjects2.GeoEvent
Set poly = Map1.TrackPolygon
Set eventPoly = Map1.TrackingLayer.AddEvent(poly, 2)
Set buffPoly = poly.Buffer(Text1.Text, Map1.FullExtent)
Set buffEventPoly = Map1.TrackingLayer.AddEvent(buffPoly, 3)
'Ellipse buffering
ElseIf Option5.Value Then
Dim arect As New MapObjects2.Rectangle
Dim elli As New MapObjects2.Ellipse
Dim eventElli As New MapObjects2.GeoEvent
Dim buffElli As New MapObjects2.Polygon
Dim buffEventElli As New MapObjects2.GeoEvent
Set arect = Map1.TrackRectangle
elli.Top = arect.Top
elli.Bottom = arect.Bottom
elli.Left = arect.Left
elli.Right = arect.Right
Set eventElli = Map1.TrackingLayer.AddEvent(elli, 2)
Set buffElli = elli.Buffer(Text1.Text, Map1.FullExtent)
Set buffEventElli = Map1.TrackingLayer.AddEvent(buffElli, 3)
End If
End Sub
Private Sub Form_Load()
Option1.Caption = "Point"
Option2.Caption = "Line"
Option3.Caption = "Rectangle"
Option4.Caption = "Polygon"
Option5.Caption = "Ellipse"
Text1.Text = "100"
Map1.TrackingLayer.SymbolCount = 4
With Map1.TrackingLayer.Symbol(0)
.SymbolType = moPointSymbol
.Style = moTriangleMarker
.Color = moRed
.Size = 3
End With
With Map1.TrackingLayer.Symbol(1)
.SymbolType = moLineSymbol
.Color = moRed
.Size = 3
End With
With Map1.TrackingLayer.Symbol(2)
.SymbolType = moFillSymbol
.Style = moGrayFill
.Color = moRed
.OutlineColor = moRed
End With
With Map1.TrackingLayer.Symbol(3)
.SymbolType = moFillSymbol
.Style = moGrayFill
.Color = moBlue
.OutlineColor = moBlue
End With
End Sub
运行结果
用mo真是累.写个毕业设计真是麻烦.