📄 form1.frm
字号:
VERSION 5.00
Object = "{C552EA90-6FBB-11D5-A9C1-00104BB6FC1C}#1.0#0"; "MapControl.ocx"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 8280
ClientLeft = 60
ClientTop = 450
ClientWidth = 9720
LinkTopic = "Form1"
ScaleHeight = 8280
ScaleWidth = 9720
StartUpPosition = 3 'Windows Default
Begin VB.Timer Timer1
Left = 9120
Top = 7920
End
Begin esriMapControl.MapControl MapControl1
Height = 8295
Left = 0
OleObjectBlob = "Form1.frx":0000
TabIndex = 0
Top = 0
Width = 9735
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private m_pGraphicsContainer As IGraphicsContainer
Private Type element
x As Double
y As Double
Number As String
End Type
Private elements(5) As element
Private Sub Form_Load()
Set m_pGraphicsContainer = MapControl1.ActiveView.GraphicsContainer
LoadAgentArray
Dim i As Integer
For i = 0 To 4
DisplayAgentLocation elements(i)
Next i
End Sub
Private Sub DisplayAgentLocation(agent As element)
Dim pPoint As IPoint
Set pPoint = New Point
pPoint.PutCoords agent.x, agent.y
Dim pElement As IElement
Set pElement = New MarkerElement
pElement.Geometry = pPoint
Dim pMarkerElement As IMarkerElement
Set pMarkerElement = pElement
Dim pFont As New stdole.StdFont
pFont.Name = "ESRI Crime Analysis"
Dim pCharMarker As ICharacterMarkerSymbol
Set pCharMarker = New CharacterMarkerSymbol
pCharMarker.Font = pFont
pCharMarker.CharacterIndex = 37
pCharMarker.Size = 20
pMarkerElement.Symbol = pCharMarker
Dim pElementProperties As IElementProperties
Set pElementProperties = pMarkerElement
pElementProperties.Name = agent.Number
m_pGraphicsContainer.AddElement pElement, 0
Timer1.Interval = 800
End Sub
Private Sub LoadAgentArray()
elements(0).Number = "001"
elements(0).x = 56.185128983308
elements(0).y = 37.556904400607
elements(1).Number = "002"
elements(1).x = 48.3732928679818
elements(1).y = 6.91047040971168
elements(2).Number = "003"
elements(2).x = 32.1487101669196
elements(2).y = 39.3596358118361
elements(3).Number = "004"
elements(3).x = 29.7450682852807
elements(3).y = 71.2078907435508
elements(4).Number = "005"
elements(4).x = 38.7587253414264
elements(4).y = 138.509863429439
End Sub
Private Sub Timer1_Timer()
Dim dMaxDistance As Double
dMaxDistance = MapControl1.Extent.Width / 20
m_pGraphicsContainer.Reset
Dim pElement As IElement
Set pElement = m_pGraphicsContainer.Next
Do While Not pElement Is Nothing
Dim pElementProperties As IElementProperties
Set pElementProperties = pElement
Dim pPoint As IPoint
Set pPoint = pElement.Geometry
pPoint.x = pPoint.x - (dMaxDistance * (Rnd - 0.5))
pPoint.y = pPoint.y - (dMaxDistance * (Rnd - 0.5))
pElement.Geometry = pPoint
Set pElement = m_pGraphicsContainer.Next
Loop
MapControl1.Refresh esriViewGraphics
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -